if __name__ == "__main__":

    N = int(eval(input()))

    h = [int(n) for n in input().split()]

    dp = [0] * int(1e5) # dp[i]はiにたどり着くコストの最小値

    # dp[0] = 0

    # dp[n] = min(dp[n-1] + abs(h[n] - h[n-1]), dp[n-2] + |h[n] - h[n-2]|)

    dp[0] = 0

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

    for i in range(2, N):

        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))

    print((dp[N-1]))

def main():

    N = int(eval(input()))

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

    dp = [-1]*N

    dp[0] = 0

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

    for i in range(2,N):

        dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]), dp[i-2] + abs(A[i] - A[i-2]))

    print((dp[N-1]))

main()
if __name__ == "__main__":
    N = int(eval(input()))
    h = [int(n) for n in input().split()]
    dp = [0] * int(1e5)  # dp[i]はiにたどり着くコストの最小値
    # dp[0] = 0
    # dp[n] = min(dp[n-1] + abs(h[n] - h[n-1]), dp[n-2] + |h[n] - h[n-2]|)
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
    print((dp[N - 1]))

def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    dp = [-1] * N
    dp[0] = 0
    dp[1] = abs(A[1] - A[0])
    for i in range(2, N):
        dp[i] = min(dp[i - 1] + abs(A[i] - A[i - 1]), dp[i - 2] + abs(A[i] - A[i - 2]))
    print((dp[N - 1]))


main()

-if __name__ == "__main__": +def main(): -    h = [int(n) for n in input().split()] -    dp = [0] * int(1e5)  # dp[i]はiにたどり着くコストの最小値 -    # dp[0] = 0 -    # dp[n] = min(dp[n-1] + abs(h[n] - h[n-1]), dp[n-2] + |h[n] - h[n-2]|) +    A = [int(i) for i in input().split()] +    dp = [-1] * N -    dp[1] = abs(h[1] - h[0]) +    dp[1] = abs(A[1] - A[0]) -        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) +        dp[i] = min(dp[i - 1] + abs(A[i] - A[i - 1]), dp[i - 2] + abs(A[i] - A[i - 2])) + + +main()