N = int(eval(input()))

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



"""

dp[i] i番目に到達するときの最小値

遷移

送るDP

i-1段目まで下記を実施

dp[i+1] = min(dp[i+1], dp[i]+コスト)

if (一段飛ばしできる余地があれば): 

    dp[i+2] = min(dp[i+2],dp[i]+コスト)



"""

INF = 10**9+7

dp = [INF]*101000

dp[0] = 0

for i in range(1,N):

    if i-2 >= 0:

        cost2 = abs(hs[i]-hs[i-2])

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

    cost1 = abs(hs[i]-hs[i-1])

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



print((dp[N-1]))


"""

dp[i] : 足場iに到達するにあたって、たどり着く最小回数

"""

INF = 10**10

dp = [INF]*110000

N = int(eval(input()))

hs  = list(map(int, input().split())) + [INF,INF]

dp[0] = 0

for i in range(N):

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

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

print((dp[N-1]))



N = int(eval(input()))
hs = list(map(int, input().split()))
"""
dp[i] i番目に到達するときの最小値
遷移
送るDP
i-1段目まで下記を実施
dp[i+1] = min(dp[i+1], dp[i]+コスト)
if (一段飛ばしできる余地があれば): 
    dp[i+2] = min(dp[i+2],dp[i]+コスト)
"""
INF = 10**9 + 7
dp = [INF] * 101000
dp[0] = 0
for i in range(1, N):
    if i - 2 >= 0:
        cost2 = abs(hs[i] - hs[i - 2])
        dp[i] = min(dp[i], dp[i - 2] + cost2)
    cost1 = abs(hs[i] - hs[i - 1])
    dp[i] = min(dp[i], dp[i - 1] + cost1)
print((dp[N - 1]))

"""
dp[i] : 足場iに到達するにあたって、たどり着く最小回数
"""
INF = 10**10
dp = [INF] * 110000
N = int(eval(input()))
hs = list(map(int, input().split())) + [INF, INF]
dp[0] = 0
for i in range(N):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(hs[i + 1] - hs[i]))
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(hs[i + 2] - hs[i]))
print((dp[N - 1]))

+""" +dp[i] : 足場iに到達するにあたって、たどり着く最小回数 +""" +INF = 10**10 +dp = [INF] * 110000 -hs = list(map(int, input().split())) -""" -dp[i] i番目に到達するときの最小値 -遷移 -送るDP -i-1段目まで下記を実施 -dp[i+1] = min(dp[i+1], dp[i]+コスト) -if (一段飛ばしできる余地があれば): -    dp[i+2] = min(dp[i+2],dp[i]+コスト) -""" -INF = 10**9 + 7 -dp = [INF] * 101000 +hs = list(map(int, input().split())) + [INF, INF] -for i in range(1, N): -    if i - 2 >= 0: -        cost2 = abs(hs[i] - hs[i - 2]) -        dp[i] = min(dp[i], dp[i - 2] + cost2) -    cost1 = abs(hs[i] - hs[i - 1]) -    dp[i] = min(dp[i], dp[i - 1] + cost1) +for i in range(N): +    dp[i + 1] = min(dp[i + 1], dp[i] + abs(hs[i + 1] - hs[i])) +    dp[i + 2] = min(dp[i + 2], dp[i] + abs(hs[i + 2] - hs[i]))