inf = float('inf')



n = int(eval(input()))

h = list(map(int, input().split())) + [inf]



dp = [inf] * (n + 1)

dp[0] = 0



# 配る

for i in range(n - 1):

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

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

print((dp[n - 1]))

def main():

    import sys

    readline = sys.stdin.readline



    inf = 10 ** 9



    n = int(readline())

    *h, = list(map(int, readline().split()))

    h = [inf] + h + [inf]  # 1-indexed化



    dp = [inf] * (n + 2)

    dp[0] = 0

    dp[1] = 0



    for i in range(1, n):  # ジャンプ元,1-indexed

        dp[i + 2] = min(

            dp[i + 2],

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



        dp[i + 1] = min(

            dp[i + 1],

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



    print((dp[n]))





if __name__ == '__main__':

    main()

inf = float("inf")
n = int(eval(input()))
h = list(map(int, input().split())) + [inf]
dp = [inf] * (n + 1)
dp[0] = 0
# 配る
for i in range(n - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
print((dp[n - 1]))

def main():
    import sys

    readline = sys.stdin.readline
    inf = 10**9
    n = int(readline())
    (*h,) = list(map(int, readline().split()))
    h = [inf] + h + [inf]  # 1-indexed化
    dp = [inf] * (n + 2)
    dp[0] = 0
    dp[1] = 0
    for i in range(1, n):  # ジャンプ元,1-indexed
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    print((dp[n]))


if __name__ == "__main__":
    main()

-inf = float("inf") -n = int(eval(input())) -h = list(map(int, input().split())) + [inf] -dp = [inf] * (n + 1) -dp[0] = 0 -# 配る -for i in range(n - 1): -    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) -    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) -print((dp[n - 1])) +def main(): +    import sys + +    readline = sys.stdin.readline +    inf = 10**9 +    n = int(readline()) +    (*h,) = list(map(int, readline().split())) +    h = [inf] + h + [inf]  # 1-indexed化 +    dp = [inf] * (n + 2) +    dp[0] = 0 +    dp[1] = 0 +    for i in range(1, n):  # ジャンプ元,1-indexed +        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) +        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) +    print((dp[n])) + + +if __name__ == "__main__": +    main()