Electron-optical system of terahertz gyrotron