N=int(eval(input()))

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

A+=[0]

A+=[0]

dp=[float("INF")]*(N+2)

dp[0]=0

dp[1]=abs(A[1]-A[0])

for i in range(N):

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

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

print((dp[N-1]))
N=int(eval(input()))

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

dp=[float("INF")]*N

dp[0]=0

dp[1]=abs(A[0]-A[1])

for i in range(2,N):

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

print((dp[-1]))

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

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

-A += [0] -A += [0] -dp = [float("INF")] * (N + 2) +dp = [float("INF")] * N -dp[1] = abs(A[1] - A[0]) -for i in range(N): -    dp[i + 1] = min(dp[i + 1], abs(A[i + 1] - A[i]) + dp[i]) -    dp[i + 2] = min(dp[i + 2], abs(A[i + 2] - A[i]) + dp[i]) -print((dp[N - 1])) +dp[1] = abs(A[0] - A[1]) +for i in range(2, N): +    dp[i] = min( +        dp[i], abs(A[i] - A[i - 1]) + dp[i - 1], abs(A[i - 2] - A[i]) + dp[i - 2] +    ) +print((dp[-1]))