# import sys

# sys.setrecursionlimit(10**5)

# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))

gete = lambda fn: fn(eval(input()))



N = gete(int)

h = geta(int)



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

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



for i in range(2, N):

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

                dp[i - 1] + abs(h[i] - h[i - 1]))



print((dp[N - 1]))

# import sys

# sys.setrecursionlimit(10**5)

# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))

gete = lambda fn: fn(eval(input()))



def main():

    N = gete(int)

    h = geta(int)



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

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



    for i in range(2, N):

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

                    dp[i - 1] + abs(h[i] - h[i - 1]))



    print((dp[N - 1]))





if __name__ == "__main__":

    main()
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(eval(input()))
N = gete(int)
h = geta(int)
dp = [0 for _ in range(N)]
dp[0], dp[1] = 0, abs(h[0] - h[1])
for i in range(2, N):
    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))
print((dp[N - 1]))

# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(eval(input()))


def main():
    N = gete(int)
    h = geta(int)
    dp = [0 for _ in range(N)]
    dp[0], dp[1] = 0, abs(h[0] - h[1])
    for i in range(2, N):
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))
    print((dp[N - 1]))


if __name__ == "__main__":
    main()

-N = gete(int) -h = geta(int) -dp = [0 for _ in range(N)] -dp[0], dp[1] = 0, abs(h[0] - h[1]) -for i in range(2, N): -    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1])) -print((dp[N - 1])) + + +def main(): +    N = gete(int) +    h = geta(int) +    dp = [0 for _ in range(N)] +    dp[0], dp[1] = 0, abs(h[0] - h[1]) +    for i in range(2, N): +        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1])) +    print((dp[N - 1])) + + +if __name__ == "__main__": +    main()