N = int(eval(input()))

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

DP = [0]*(N+1)  #DP[i]に来るための最小コスト

def dH(i,j):

  return abs(H[i-1] - H[j-1])

DP[2] = dH(1,2)

for i in range(3,N+1):

  DP[i] = min( DP[i-2] + dH(i-2, i) , DP[i-1] + dH(i-1, i) )

print((DP[N]))
#!/usr/bin/env python3

# -*- coding:utf-8 -*-



import sys



def main():

    input = sys.stdin.readline

    N = int(eval(input()))

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

    def cost(i, jp):

        return abs(H[i-1] - H[i+jp-1])

    dp = [0]*(N+1)

    dp[2] = cost(1, 1)

    for i in range(3,N+1):

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

    print((dp[N]))





if __name__=='__main__':

    main()

N = int(eval(input()))
H = list(map(int, input().split()))
DP = [0] * (N + 1)  # DP[i]に来るための最小コスト


def dH(i, j):
    return abs(H[i - 1] - H[j - 1])


DP[2] = dH(1, 2)
for i in range(3, N + 1):
    DP[i] = min(DP[i - 2] + dH(i - 2, i), DP[i - 1] + dH(i - 1, i))
print((DP[N]))

#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import sys


def main():
    input = sys.stdin.readline
    N = int(eval(input()))
    H = list(map(int, input().split()))

    def cost(i, jp):
        return abs(H[i - 1] - H[i + jp - 1])

    dp = [0] * (N + 1)
    dp[2] = cost(1, 1)
    for i in range(3, N + 1):
        dp[i] = min(dp[i - 1] + cost(i - 1, 1), dp[i - 2] + cost(i - 2, 2))
    print((dp[N]))


if __name__ == "__main__":
    main()

-N = int(eval(input())) -H = list(map(int, input().split())) -DP = [0] * (N + 1)  # DP[i]に来るための最小コスト +#!/usr/bin/env python3 +# -*- coding:utf-8 -*- +import sys -def dH(i, j): -    return abs(H[i - 1] - H[j - 1]) +def main(): +    input = sys.stdin.readline +    N = int(eval(input())) +    H = list(map(int, input().split())) + +    def cost(i, jp): +        return abs(H[i - 1] - H[i + jp - 1]) + +    dp = [0] * (N + 1) +    dp[2] = cost(1, 1) +    for i in range(3, N + 1): +        dp[i] = min(dp[i - 1] + cost(i - 1, 1), dp[i - 2] + cost(i - 2, 2)) +    print((dp[N])) -DP[2] = dH(1, 2) -for i in range(3, N + 1): -    DP[i] = min(DP[i - 2] + dH(i - 2, i), DP[i - 1] + dH(i - 1, i)) -print((DP[N])) +if __name__ == "__main__": +    main()