N=int(eval(input()))

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



c=[0]*N

c[1]=abs(h[1]-h[0])

for i in range(2,N):

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

print((c[-1]))
# 埋める配列

# dp[x] = 足場0からスタートして足場xに着地するときに足場xまでに払うコストの最小値



# 計算方法

# dp[0] = 0

# dp[x] = min(dp[x - 1] + |h[x] - h[x - 1]|, dp[x - 2] + |h[x] - h[x - 2]|)



# 埋める順番

# xが小さい順



N = int(eval(input()))

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



dp = [0] * (N + 5)



for i in range(1, N):

    if i == 1:

        dp[i] = dp[i - 1] + abs(H[i] - H[i - 1])

    else:

        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]))
N = int(eval(input()))
h = list(map(int, input().split()))
c = [0] * N
c[1] = abs(h[1] - h[0])
for i in range(2, N):
    c[i] = min(c[i - 2] + abs(h[i] - h[i - 2]), c[i - 1] + abs(h[i] - h[i - 1]))
print((c[-1]))

# 埋める配列
# dp[x] = 足場0からスタートして足場xに着地するときに足場xまでに払うコストの最小値
# 計算方法
# dp[0] = 0
# dp[x] = min(dp[x - 1] + |h[x] - h[x - 1]|, dp[x - 2] + |h[x] - h[x - 2]|)
# 埋める順番
# xが小さい順
N = int(eval(input()))
H = list(map(int, input().split()))
dp = [0] * (N + 5)
for i in range(1, N):
    if i == 1:
        dp[i] = dp[i - 1] + abs(H[i] - H[i - 1])
    else:
        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]))

+# 埋める配列 +# dp[x] = 足場0からスタートして足場xに着地するときに足場xまでに払うコストの最小値 +# 計算方法 +# dp[0] = 0 +# dp[x] = min(dp[x - 1] + |h[x] - h[x - 1]|, dp[x - 2] + |h[x] - h[x - 2]|) +# 埋める順番 +# xが小さい順 -h = list(map(int, input().split())) -c = [0] * N -c[1] = abs(h[1] - h[0]) -for i in range(2, N): -    c[i] = min(c[i - 2] + abs(h[i] - h[i - 2]), c[i - 1] + abs(h[i] - h[i - 1])) -print((c[-1])) +H = list(map(int, input().split())) +dp = [0] * (N + 5) +for i in range(1, N): +    if i == 1: +        dp[i] = dp[i - 1] + abs(H[i] - H[i - 1]) +    else: +        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]))