MARG: MAstering Risky Gap Terrains for Legged Robots with Elevation Mapping