n=int(eval(input()))

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

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

dp[0]=0;dp[1]=abs(l[0]-l[1])

for i in range(2,n):

  for j in range(1,3):

    dp[i]=min(dp[i-j]+abs(l[i]-l[i-j]),dp[i])

print((dp[-1]))

n=int(eval(input()))

dp=[10**4*n]*n

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

dp[0]=0

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

for i in range(2,n):

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

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

n = int(eval(input()))
dp = [10**4 * n] * n
l = list(map(int, input().split()))
dp[0] = 0
dp[1] = abs(l[0] - l[1])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(l[i] - l[i - 1]), dp[i - 2] + abs(l[i] - l[i - 2]))
print((dp[-1]))

+dp = [10**4 * n] * n -dp = [float("INF")] * n -    for j in range(1, 3): -        dp[i] = min(dp[i - j] + abs(l[i] - l[i - j]), dp[i]) +    dp[i] = min(dp[i - 1] + abs(l[i] - l[i - 1]), dp[i - 2] + abs(l[i] - l[i - 2]))