The Castelnuovo-Mumford regularity and the Buchsbaum property of projective varieties