def ch_min(a, b):

    if (a > b):

        a = b

    return a





if __name__ == "__main__":

    N = int(eval(input()))

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

    INF = 10 ** 10

    dp = [INF] * 100010

    dp[0] = 0

    for i in range(N - 1):

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

        if (i < N - 2):

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

    print((dp[N - 1]))

N = int(eval(input()))

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

x = [0] * N

x[1] = x[0] + abs(h[1] - h[0])

for i in range(2, N):

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

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

print((x[N-1]))

def ch_min(a, b):
    if a > b:
        a = b
    return a


if __name__ == "__main__":
    N = int(eval(input()))
    h = list(map(int, input().split()))
    INF = 10**10
    dp = [INF] * 100010
    dp[0] = 0
    for i in range(N - 1):
        dp[i + 1] = ch_min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        if i < N - 2:
            dp[i + 2] = ch_min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
    print((dp[N - 1]))

N = int(eval(input()))
h = list(map(int, input().split()))
x = [0] * N
x[1] = x[0] + abs(h[1] - h[0])
for i in range(2, N):
    x[i] = min(x[i - 1] + abs(h[i] - h[i - 1]), x[i - 2] + abs(h[i] - h[i - 2]))
print((x[N - 1]))

-def ch_min(a, b): -    if a > b: -        a = b -    return a - - -if __name__ == "__main__": -    N = int(eval(input())) -    h = list(map(int, input().split())) -    INF = 10**10 -    dp = [INF] * 100010 -    dp[0] = 0 -    for i in range(N - 1): -        dp[i + 1] = ch_min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1])) -        if i < N - 2: -            dp[i + 2] = ch_min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2])) -    print((dp[N - 1])) +N = int(eval(input())) +h = list(map(int, input().split())) +x = [0] * N +x[1] = x[0] + abs(h[1] - h[0]) +for i in range(2, N): +    x[i] = min(x[i - 1] + abs(h[i] - h[i - 1]), x[i - 2] + abs(h[i] - h[i - 2])) +print((x[N - 1]))