Dynamical theory of electron diffraction for a finite polyhedral crystal. I