High-efficiency terahertz beam scanning based on topologically optimized freestanding metasurfaces