import numpy as np

n = int(eval(input()))

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

dp = [1000000000]*n

dp[0]=0

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

for i in range(1,n-1):

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

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

print((dp[n-1]))    
def cost(a,b):

    return abs(a-b)



INF = 10**9

N = int(eval(input()))

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

#dp[i][0]:V_iに行かない

#dp[i][1]:V_iに行く

dp = [ INF for __ in range(N)]

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]))
import numpy as np

n = int(eval(input()))
h = [int(i) for i in input().split()]
dp = [1000000000] * n
dp[0] = 0
dp[1] = np.abs(h[1] - h[0])
for i in range(1, n - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + np.abs(h[i] - h[i + 1]))
    dp[i + 1] = min(dp[i + 1], dp[i - 1] + np.abs(h[i - 1] - h[i + 1]))
print((dp[n - 1]))

def cost(a, b):
    return abs(a - b)


INF = 10**9
N = int(eval(input()))
H = list(map(int, input().split()))
# dp[i][0]:V_iに行かない
# dp[i][1]:V_iに行く
dp = [INF for __ in range(N)]
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]))

-import numpy as np +def cost(a, b): +    return abs(a - b) -n = int(eval(input())) -h = [int(i) for i in input().split()] -dp = [1000000000] * n + +INF = 10**9 +N = int(eval(input())) +H = list(map(int, input().split())) +# dp[i][0]:V_iに行かない +# dp[i][1]:V_iに行く +dp = [INF for __ in range(N)] -dp[1] = np.abs(h[1] - h[0]) -for i in range(1, n - 1): -    dp[i + 1] = min(dp[i + 1], dp[i] + np.abs(h[i] - h[i + 1])) -    dp[i + 1] = min(dp[i + 1], dp[i - 1] + np.abs(h[i - 1] - h[i + 1])) -print((dp[n - 1])) +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]))