if __name__=='__main__':

    N = int(eval(input()))

    hi = [int(i) for i in input().split()]

    dp = [0 for i in range(N)]

    dp[1] = abs(hi[0]-hi[1])

    

    for i in range(2,N):

        dp_1 = dp[i-1] + abs(hi[i]-hi[i-1])

        dp_2 = dp[i-2] + abs(hi[i]-hi[i-2])

        dp[i] = min(dp_1,dp_2)

            

    print((dp[N-1]))
if __name__=='__main__':

    N = int(eval(input()))

    hi = list(map(int,input().split()))

    dp = [0]*N

    dp[1] = abs(hi[0]-hi[1])

    

    for i in range(2,N):

        dp_1 = dp[i-1] + abs(hi[i]-hi[i-1])

        dp_2 = dp[i-2] + abs(hi[i]-hi[i-2])

        dp[i] = dp_1 if dp_1 < dp_2 else dp_2

            

    print((dp[-1]))
if __name__ == "__main__":
    N = int(eval(input()))
    hi = [int(i) for i in input().split()]
    dp = [0 for i in range(N)]
    dp[1] = abs(hi[0] - hi[1])
    for i in range(2, N):
        dp_1 = dp[i - 1] + abs(hi[i] - hi[i - 1])
        dp_2 = dp[i - 2] + abs(hi[i] - hi[i - 2])
        dp[i] = min(dp_1, dp_2)
    print((dp[N - 1]))

if __name__ == "__main__":
    N = int(eval(input()))
    hi = list(map(int, input().split()))
    dp = [0] * N
    dp[1] = abs(hi[0] - hi[1])
    for i in range(2, N):
        dp_1 = dp[i - 1] + abs(hi[i] - hi[i - 1])
        dp_2 = dp[i - 2] + abs(hi[i] - hi[i - 2])
        dp[i] = dp_1 if dp_1 < dp_2 else dp_2
    print((dp[-1]))

-    hi = [int(i) for i in input().split()] -    dp = [0 for i in range(N)] +    hi = list(map(int, input().split())) +    dp = [0] * N -        dp[i] = min(dp_1, dp_2) -    print((dp[N - 1])) +        dp[i] = dp_1 if dp_1 < dp_2 else dp_2 +    print((dp[-1]))