Is your increase in gravitational potential energy the same in both cases? When Climbing a mountain on a zigzag path and on a straight path