INF=10**15

N=int(eval(input()))

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

dp=[INF for i in range(N)]

dp[0]=0

for i in range(1,N):

    if i>1:

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

    else:

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

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

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

Cost=[0 for i in range(N)]

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

for i in range(2,N):

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

print((Cost[N-1]))
INF = 10**15
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [INF for i in range(N)]
dp[0] = 0
for i in range(1, N):
    if i > 1:
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
    else:
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
print((dp[N - 1]))

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

-INF = 10**15 -h = list(map(int, input().split())) -dp = [INF for i in range(N)] -dp[0] = 0 -for i in range(1, N): -    if i > 1: -        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) -    else: -        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]) -print((dp[N - 1])) +H = list(map(int, input().split())) +Cost = [0 for i in range(N)] +Cost[1] = abs(H[1] - H[0]) +for i in range(2, N): +    Cost[i] = min( +        Cost[i - 2] + abs(H[i] - H[i - 2]), Cost[i - 1] + abs(H[i] - H[i - 1]) +    ) +print((Cost[N - 1]))