N=int(eval(input()))

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

dp=[0]*N

for i in range(N):

  if i==0:

    dp[i]=0

  elif i==1:

    dp[i]=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[-1]))    
N=int(eval(input()))

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

dp=[10000000000000]*(N+2)

#初期状態

dp[0]=0

#配るDP

for i in range(N):

    try:

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

    except IndexError:

        pass

    try:

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

    except IndexError:

        pass

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

N = int(eval(input()))
h = list(map(int, input().split()))
dp = [10000000000000] * (N + 2)
# 初期状態
dp[0] = 0
# 配るDP
for i in range(N):
    try:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    except IndexError:
        pass
    try:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
    except IndexError:
        pass
print((dp[N - 1]))

-dp = [0] * N +dp = [10000000000000] * (N + 2) +# 初期状態 +dp[0] = 0 +# 配るDP -    if i == 0: -        dp[i] = 0 -    elif i == 1: -        dp[i] = 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[-1])) +    try: +        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) +    except IndexError: +        pass +    try: +        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) +    except IndexError: +        pass +print((dp[N - 1]))