N=int(eval(input()))

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

dp=[0]*(N+5)

dp[0]=0

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

for i in range(2,N):

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

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

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

#print(H)

INF=1000000000

dp=[INF]*(N+1)

#print(dp)

dp[0]=0

#print(dp[0])

#print(H[1],H[0])

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

for i in range(2,N):

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

print((dp[N-1]))

  
N = int(eval(input()))
H = [int(i) for i in input().split()]
dp = [0] * (N + 5)
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i - 2] + abs(H[i - 2] - H[i]), dp[i - 1] + abs(H[i - 1] - H[i]))
print((dp[N - 1]))

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

-H = [int(i) for i in input().split()] -dp = [0] * (N + 5) +H = list(map(int, input().split())) +# print(H) +INF = 1000000000 +dp = [INF] * (N + 1) +# print(dp) -dp[1] = abs(H[1] - H[0]) +# print(dp[0]) +# print(H[1],H[0]) +dp[1] = dp[0] + abs(H[1] - H[0])