peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
h = [int(i) for i in input().split(" ")]
dp = [float("inf")] * n

dp[0] = 0
dp[1] = dp[0] + abs(h[0] - h[1])
for i in range(1, n-1, 1):
  dp[i+1] = min(dp[i-1] + abs(h[i-1] - h[i+1]), dp[i] + abs(h[i] - h[i+1]))
  
print(dp[-1])
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

INF = 10 ** 10

n = int(input())
h = [0] + list(map(int, input().split()))
dp = [INF] + [INF] * n
dp[1] = 0

def chmin(dp_table, index, value):
    if dp_table[index] > value:
        dp_table[index] = value

for i in range(2, n+1):
    chmin(dp, i, dp[i-1] + abs(h[i] - h[i-1]))
    chmin(dp, i, dp[i-2] + abs(h[i] - h[i-2]))

print(dp[n])
import sys
n=int(input())
h=list(map(int,input().split()))
if n==2:
  print(abs(h[1]-h[0]))
  sys.exit()
c=[float('inf')]*n
c[0]=0
c[1]=abs(h[1]-h[0])
for i in range(n-2):
  c[i+2]=min(c[i]+abs(h[i+2]-h[i]),c[i+1]+abs(h[i+2]-h[i+1]))
print(c[n-1])
N = int(input())

heights = tuple(map(int, input().split(' ')))

dp = [0] * (N + 1)

dp[1] = 0
dp[2] = abs(heights[0] - heights[1])

for hi, i in enumerate(range(3, N + 1), start=2):
    dp[i] = min(
        dp[i - 1] + abs(heights[hi] - heights[hi - 1]),
        dp[i - 2] + abs(heights[hi] - heights[hi - 2]),
    )

print(dp[N])
N = int(input())
h = list(map(int, input().split()))

dp_table = [float("inf")]*N # 0~N-1まで
dp_table[0] = 0

for i in range(N-1): # 0~N-1までだが+1して扱う(1~N)
    dp_table[i+1] = min(dp_table[i]+abs(h[i]-h[i+1]), dp_table[i+1])
    if i-1>=0:
        dp_table[i+1] = min(dp_table[i-1]+abs(h[i-1]-h[i+1]), dp_table[i+1])
        
print(dp_table[N-1])
INT_MAX= 100000000
n=int(input())
dp  = [INT_MAX]*(100001)
h=[int(X) for X in input().split()]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):

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

print(dp[n-1])
n = int(input())
h = [int(x) for x in input().split()]

dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2, n):
    dp[i] = min( dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]) )

print(dp[n-1])
N = int(input())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
dp[0]=0
for i in range(N):
    for j in range(1,3):
        if i+j<N:
            dp[i+j] = min(dp[i]+abs(H[i]-H[i+j]),dp[i+j])
print(dp[N-1])
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n

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

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[-1])
N = int(input())
h = list(map(int, input().split()))
ans = [0] * N
ans[0] = 0
ans[1] = abs(h[0]-h[1])
for i in range(2, N):
    ans[i] = min(ans[i-1]+abs(h[i-1]-h[i]), ans[i-2]+abs(h[i-2]-h[i]))
print(ans[-1])
times = int(input())
line = input()
list1 = []
if times <= 1:
  print("%s" % 0)
else:
  for i in line.split():
    if i:
      list1.append(int(i))
  mem = [0] * times
  mem[-2] = abs(list1[-1] - list1[-2])
  for i in range(len(list1)-3, -1, -1):
    step1 = abs(list1[i] - list1[i+1]) + mem[i+1]
    step2 = abs(list1[i] - list1[i+2]) + mem[i+2]
    mem[i] = min(step1,step2)
  print("%s" % mem[0])
n = int(input())
l = [int(x) for x in input().split()] 
dp = [float('inf')] * n  
dp[0] = 0
for i in range(n):
    for j in (i+1, i+2):
        if j < n:
            dp[j] = min(dp[j], dp[i]+abs(l[i]-l[j]))
print(dp[n-1])
# DPをとく
inf=10**10
N=int(input())
H=list(map(int,input().split()))
dp = [inf for _ in range(N)] # 足場Nまでにたどり着くときの最小コストとする
dp[0]=0
for i in range(N):
    if i+1<N:
        dp[i+1] = min(dp[i+1],dp[i]+abs(H[i+1]-H[i]))
    if i+2<N:
        dp[i+2] = min(dp[i+2],dp[i]+abs(H[i+2]-H[i]))
print(dp[N-1])
N = int(input())
H = list(map(int, input().split()))
def solve(H):
    dp = [0]*N
    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]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]))
    ans = dp[-1]
    return ans
print(solve(H))
def frog(l,n):
  dp=[0]*n
  dp[0]=0
  dp[1]=abs(l[1]-l[0])
  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]))
  return dp[n-1]
n=int(input())
l=list(map(int,input().split()))
print(frog(l,n))
N = int(input())
h = [int(val) for val in input().split(' ')]
dp = [0, abs(h[0]-h[1])]

for i in range(len(h)-2):
    step1_cost = dp[i+1] + abs(h[i+1]-h[i+2])
    step2_cost = dp[i] + abs(h[i]-h[i+2])
    dp.append(min(step1_cost, step2_cost))
print(dp[-1])
n = int(input())
h = list(map(int, input().split()))

dp=[0] * n
for i in range(1, n):
  if i - 2 < 0:
    dp[i] = dp[i-1] + abs(h[i] - h[i-1])
  else:
    dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]) ,dp[i-1]+abs(h[i]-h[i-1]) )
  
print(dp[n-1])
import sys
input=sys.stdin.readline
n=int(input())
h=tuple(map(int,input().split()))

dp=[0]*n
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))

print(dp[-1])
n = int(input())
h = list(map(int,input().split()))

cost = [0]*(n)
cost[1] = abs(h[0]-h[1])

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[-1])
N = int(input())
h = list(map(int, input().split())) + [0]*100010

dp = [float("inf")]*100010
dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
    # print(dp)
print(dp[N-1])
def cal_cost(co, h, i, j):
    return co + abs(h[i]-h[j])

n = int(input())
h = [int(i) for i in input().split(" ")]
lis = [0 for i in range(n)]
lis[1] = cal_cost(lis[0], h, 0, 1)
for i in range(2, n):
    temp1 = cal_cost(lis[i-2], h, i-2, i)
    temp2 = cal_cost(lis[i-1], h, i-1, i)
    lis[i] = min(temp1, temp2)
print(lis[-1])
N = int(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(input())
H = [int(i) for i in input().split()]

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

if N == 2:
    print(dp[-1])

else:
    for i in range(2, N):
        dp[i] = min(dp[i-2] + abs(H[i]-H[i-2]), dp[i-1] + abs(H[i]-H[i-1]))
    print(dp[-1])
n = int(input())
hlist = list(map(int, input().split()))

# The minimum cost to reach step i (1->n)
dp = [0]*(n+1)
dp[1] = 0 # 1->1

for i in range(2, n+1):
    dp[i] = min(dp[i-1] + abs(hlist[i-2] - hlist[i-1]), (dp[i-2] + abs(hlist[i-3] - hlist[i-1]) if i>2 else 10**9))

print(dp[n])
N = int(input())
h = list(map(int, input().split())) #1-index

dp = [float('inf')]*(N)

def chmin(a,b):
    if a >= b:
        return b
    else:
        return a

dp[0] = 0
for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    
    if i >= 2:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
    
print(dp[N-1])
n = int(input())
h = list(map(int, input().split()))

dp = [0 for _ in range(n)]
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(
        dp[i - 2] + abs(h[i] - h[i - 2]),
        dp[i - 1] + abs(h[i] - h[i - 1]))
print(dp[-1])
N = int(input())
h = list(map(int,input().split()))

INF = float('inf')
dp = [INF] * N
dp[0] = 0
for i in range(1,N):
  dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])
a=int(input())
b=list(map(int,input().split()))
dp=[0]
dp.append(abs(b[0]-b[1]))
for i in range(2,len(b)):
    h1=abs(b[i]-b[i-1])+dp[i-1]
    h2=abs(b[i-2]-b[i])+dp[i-2]
    dp.append(min(h1,h2))
print(dp[a-1])
n = int(input())
height = list(map(int,input().split()))
cost = []

for i in range(n):
  if i == 0:
    cost.append(0)
  elif i == 1:
    cost.append(abs(height[i]-height[0]))
  else:
    a = cost[-1] + abs(height[i]-height[i-1])
    b = cost[-2] + abs(height[i]-height[i-2])
    cost.append(min([a,b]))
print(cost[-1])
n = int(input())
h = list(map(int,input().split()))

dp = [0] * n

for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[1] - h[0])
    else:
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2])

print(dp[-1])
N = int(input())
h = list(map(int, input().split()))

dp = [0]*N
dp[1] = abs(h[1]-h[0])

for i in range(2,N):
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))

print(dp[-1])
n = int(input())
l = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(l[1] - l[0])
for i in range(2,n):
    dp[i] = min(dp[i-2]+abs(l[i]-l[i-2]),dp[i-1]+abs(l[i] - l[i-1]))
print(dp[n-1])
import sys
N=int(input())
l=[int(x) for x in input().split()]
l1=[sys.maxsize]*(N)
l1[0]=0
for i in range(N):
    for j in range(i+1,i+3):
        if j<N:
            l1[j]=min(l1[j],l1[i]+abs(l[j]-l[i]))
print(l1[N-1])
n=int(input())
arr=[int(i) for i in input().split()]
dp=[0]*(n+1)
dp[2]=abs(arr[0]-arr[1])
for i in range(3,n+1):
    dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]))
 
print(dp[n])
# 参考：
# https://qiita.com/drken/items/dc53c683d6de8aeacf5a

# ver 2,振り返る DP

n=int(input())
a=list(map(int,input().split()))

# dp には 足場(i)へ至る最小コストが入る。
dp=[float("inf")]*(n)

# 振り返り起点(i==2)までのdp値は埋めておく。
dp[0]=0
dp[1]=abs(a[1]-a[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]))
print(dp[-1])
n = int(input())
h = [0] + list(map(int, input().split()))

dp = [0] * (n + 1)
dp[1] = 0
dp[2] = dp[1] + abs(h[2] - h[1])

for i in range(3, n + 1):
	dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
				dp[i - 1] + abs(h[i] - h[i - 1]))

print(dp[n])
import math
from decimal import *

n = int(input())
nos = list(map(int, input().split()))
arr = [0 for i in range(n)]
if(n>1):
    arr[1] = abs(nos[1]-nos[0])
for i in range(2, n):
    a ,b = abs(nos[i]-nos[i-1])+arr[i-1], abs(nos[i]-nos[i-2])+arr[i-2]
    if(a>b):
        arr[i]=b
    else:
        arr[i] = a
print(arr[n-1])
n=int(input())
h=[int(i) for i in input().split(' ')]


dp=[0]*(n)
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    t1=dp[i-2]+abs(h[i]-h[i-2])
    t2=dp[i-1]+abs(h[i]-h[i-1])
    dp[i]=min(t1,t2)

    
print(dp[n-1])
import sys
#import numpy as np
#from collections import defaultdict
#import math
#from collections import deque

input = sys.stdin.readline



def main():


    N = int(input())
    H = list(map(int,input().split()))
    H = [10**6] + H
    dp= [0] *(N+1)

    for i in range(2,N+1):
        dp[i]= min(dp[i-2]+abs(H[i]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]))

    print(dp[N])





if __name__ == "__main__":
    main()
N = int(input())
l = list(map(int,input().split()))
m = {0:0,1:abs(l[1]-l[0])}
for i in range(2,N):
    m[i] = min(m[i-1]+abs(l[i]-l[i-1]),m[i-2]+abs(l[i]-l[i-2]))
print (m[N-1])
N = int(input())
steps = list(map(int, input().split(" ")))

costs = [None] * N
costs[0] = 0
costs[1] = abs(steps[1] - steps[0])

for i in range(2, N):
    cost1 = costs[i-1] + abs(steps[i-1] - steps[i])
    cost2 = costs[i-2] + abs(steps[i-2] - steps[i])
    costs[i] = min(cost1, cost2)

print(costs[N-1])
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
# from functools import lru_cache
# @lru_cache(maxsize=None)


n = int(input())
h = list(map(int, input().split()))
cost = [0]*n

cost[0] = 0
cost[1] = abs(h[1]-h[0])

for i in range(2,n):
    cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2]+abs(h[i]-h[i-2]))
print(cost[n-1])
n = int(input())
arr = list(map(int,input().strip().split(" ")))

dp = [0]*n
dp[0] = 0
dp[1] = abs(arr[0]-arr[1])
for i in range(2,n):
    p = abs(arr[i]-arr[i-1])
    q = abs(arr[i]-arr[i-2])
    dp[i] = min(p+dp[i-1],q+dp[i-2])
print(dp[n-1])
n = int(input())
h = [int(i) for i in input().split()]
m = [0, abs(h[0]-h[1])]
for i in range(2, n):
    v = min(m[0]+abs(h[i-2]-h[i]), m[1]+abs(h[i-1]-h[i]))
    m = [m[1], v]
print(m[1])
N = int(input())
h = list(map(int, input().split()))
INF = 10 ** 9
dp = [INF] * N
dp[0] = 0

for i in range(N - 1):
    if i == N - 2:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    else:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))

print(dp[-1])
N=int(input())
h=list(map(int, input().split()))

dp=[float("inf")]*N
dp[0]=0

for i in range(1, N):
	if i==1:
		dp[i]=min(dp[i], abs(h[i]-h[i-1]))
	else:
		dp[i]=min(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
		dp[i]=min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])
N = int(input())
H = list(map(int, input().split()))

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

dp = [1e7]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2, N):
    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(input())
h = [None] + list(map(int, input().split()))

dp = [None for _ in range(n+1)]
for k in range(1,n+1):
  if k == 1:
    dp[k] = 0
  elif k == 2:
    dp[k] = abs(h[2] - h[1])
  else:
    dp[k] = min(
      dp[k-1] + abs(h[k] - h[k-1]),
      dp[k-2] + abs(h[k] - h[k-2])
    )
print(dp[k])
N=int(input())
h=list(map(int,input().split()))
cost=[0,abs(h[1]-h[0])]
for i in range(2,N):
    cost.append(min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2])))
print(cost[-1])
import numpy as np

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

dp=np.zeros(N+1,dtype=int)

dp[0]=0
dp[1]=0
for i in range(1,N):
    if i==1:
        dp[i+1] = abs(H[1]-H[0])
    else:
        dp[i+1] = min( dp[i] + abs( H[i] - H[i-1] ), dp[i-1] + abs( H[i] - H[i-2] ) )

# print(dp)
print(dp[N])
N = int(input())
h = list(map(int, input().split()))

dp = [float('inf')] * 100010

dp[0] = 0

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])
N  = int(input())
H = list(map(int, input().split()))

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

for i in range(2, N):
    dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]), dp[i-1]+abs(H[i]-H[i-1]))
print(dp[-1])
import numpy as np

n = int(input())
h = np.array(list(map(int, input().split())))

dp = np.full_like(h, np.inf)

dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, len(h)):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[(len(h) - 1)])
input1 = input()
input2 = input()

N = int(input1)
h = list(map(int,input2.split()))

c = [0,abs(h[1]-h[0])]

for i in range(2,N):
  c.append(min(c[i-1]+abs(h[i]-h[i-1]),c[i-2]+abs(h[i]-h[i-2])))

print(c.pop())
n=int(input())
h=list(map(int,input('').split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(abs(h[i-1]-h[i])+dp[i-1],abs(h[i-2]-h[i])+dp[i-2])
print(dp[-1])
N=int(input())
*h,=map(int,input().split())

dp = [0]*N

for i in range(1,N):
  if i == 1:
    dp[i] = dp[0]+abs(h[i]-h[0])
  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(input())
h = list(map(int,input().split()))
dp = [100010]*N
dp[0] = 0
for i in range(1,N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])
n = int(input())
l = list(map(int, input().split()))
dp = [0]*n

for i in range(1,n):
  d1 = dp[i-1] + abs(l[i] - l[i-1])
  if i > 1:
    d2 = dp[i-2] + abs(l[i] - l[i-2])
    if d1 > d2:
      d1 = d2
  dp[i] = d1
print(dp[-1])
#!/usr/bin/env python3



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

dp = [float('inf') for i in range(N+1)]

dp[1] = 0
dp[2] = abs(H[1]-H[0])
for i in range(3, N+1):
    dp[i] = min(dp[i-1]+abs(H[i-1]-H[i-2]), dp[i-2]+abs(H[i-1]-H[i-3]))

print(dp[N])
n=int(input())
a=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(a[1]-a[0])
for i in range(2,n):
    dp[i]=min(abs(a[i]-a[i-2])+dp[i-2],abs(a[i]-a[i-1])+dp[i-1])
print(dp[n-1])
N = int(input())
h = list(map(int,input().split()))
n = 2
cost = [0]*N
cost[1] = abs(h[1]-h[0])
for n in range(2,N):
    cost[n] = min(cost[n-1]+abs(h[n-1]-h[n]),cost[n-2]+abs(h[n-2]-h[n]))
    
print(cost[N-1])
import sys
n = int(input())
a = list(map(int,input().split()))

dp = [sys.maxsize]*(n)
dp[0] = 0
for i in range(n):
  for j in range(i+1,i+2+1):
    if j<n :
      dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]))
                  
                  
print(dp[n-1])
n=int(input())
li = list(map(int,input().split()))

dp = n* [10**9]
#print(dp)
dp[0]=0
dp[1]=abs(li[1]-li[0])
for i in range(2, n):
    dp[i]=min(dp[i-1] + abs(li[i] - li[i-1]),dp[i-2] + abs(li[i] - li[i-2]) )
#print(dp)
print(dp[-1])
N=int(input())
h=list(map(int,input().split()))

dp=[-1]*(N+1)
dp[1]=0
dp[2]=abs(h[2-1]-h[1-1])

for i in range(3,N+1):
  dp[i]=min(abs(h[i-1]-h[i-2])+dp[i-1],abs(h[i-1]-h[i-3])+dp[i-2])
  
print(dp[N])
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(readline().rstrip())
H = list(map(int, readline().split()))

LIM = 10 ** 9
dp = [LIM] * N
dp[0] = 0
for i in range(N):
    if i+1 < N:
        dp[i+1] = min(dp[i+1], dp[i] + abs(H[i] - H[i+1]))
    if i+2 < N:
        dp[i+2] = min(dp[i+2], dp[i] + abs(H[i] - H[i+2]))

ans = dp[-1]
print(ans)
a=int(input())

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

res = [float('inf')]*a
res[0] = 0

for i in range(1, a):
    for j in range(i-2, i):
        res[i] = min([res[i], res[j]+abs(t[i]-t[j])])
        
print(res[-1])
N, = map(int, input().split())
H = list(map(int, input().split()))

DP = [0] * N

for i in range(1, N):
    DP[i] = min(abs(H[i] - H[max(i - 1, 0)]) + DP[max(i - 1, 0)], abs(H[i] - H[max(i - 2, 0)]) + DP[max(i - 2, 0)])

print(DP[N - 1])
n = int(input())
h = list(map(int,input().split()))

cst = [0 for i in range(n+10)]
cst[0] = 0
cst[1] = abs(h[0]-h[1])

for i in range(2,n):
    cst[i] = min(cst[i-2]+abs(h[i-2]-h[i]) , cst[i-1]+abs(h[i-1]-h[i]))

print(cst[n-1])
# Frog1
N = int(input())
h = list(map(int, input().split()))
inf = float("inf")
dp = [inf for _ in range(N)]
dp[0] = 0
for i in range(N):
    for j in (1, 2):
        if i + j >= N:
            continue
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i+j]))
print(dp[-1])
n = int(input())
h = list(map(int, input().split()))

dp = [0, abs(h[0] - h[1])]

for i in range(2, n):
    dp.append(min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i])))
#print(dp)
print(dp[-1])
N = int(input())
H = list(map(int, input().split()))
for _ in range(10):
    H.append(10**9)
dp = [10**9] * (N+2)
dp[0] = 0
# 配る方式
for i in range(N):
    dp[i+1] = min(dp[i] + abs(H[i]-H[i+1]),dp[i+1])
    dp[i+2] = min(dp[i] + abs(H[i]-H[i+2]), dp[i+2])
print(dp[N-1])
import numpy as np

N = int(input())
hs = np.array(list(map(int, input().split())))

i = 0
total_cost = 0

a = np.zeros(N, int)
a[0] = 0
a[1] = abs(hs[1] - hs[0])
for i in range(2, N):
    a[i] = min(a[max(i-2,0)] + abs(hs[i] - hs[max(i-2,0)]),
               a[max(i-1,0)] + abs(hs[i] - hs[max(i-1,0)]))
print(a[-1])
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
  dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i]- h[i-1]))

print(dp[-1])
N = int(input())
h = list(map(int,input().split()))

cost = [0,abs(h[1]-h[0])]
for i in range(1,N-1):
    cost.append( min(cost[i]+abs(h[i+1]-h[i]), cost[i-1]+abs(h[i+1]-h[i-1])) )
print(cost[-1])
n=int(input())
l=list(map(int,input().split()))

dp=[0]*n
dp[0]=0
dp[1]=abs(l[1]-l[0])
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(input())
h=list(map(int,input().split()))

dp=[-1]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(   abs(h[i]-h[i-1])+dp[i-1] ,abs(h[i]-h[i-2])+dp[i-2]  )
#print(dp)
print(dp[-1])
# A
# 若干解説を見た
# 2020/04/27  17:5-
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n
for i in range(1, n):
    if i == 1:
        dp[i] = abs(h[i] - h[i-1])
    else:
        dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i]-h[i-1]))
        
print(dp[-1])
INF=int('fffFFFFffffFFFF',16)

n=int(input())
h=list(map(int,input().split()))
dp=[INF] * n

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

for i in range(2,n):
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
print(dp[n-1])
n = int(input())
hs = list(map(int, input().split()))

results = list()

results.append(0)
results.append(abs(hs[0] - hs[1]))

for i in range(2, n):
    results.append(min(abs(hs[i]-hs[i-2]) + results[i-2], abs(hs[i]-hs[i-1]) + results[i-1]))

print(results[n-1])
#最初に置いておくもの
import sys
sys.setrecursionlimit(500000) 
input=sys.stdin.readline


N=int(input())
A = list(map(int, input().split()))
inf=float('inf')
dp=[inf]*N

def chmin(a,b):
    return min(a,b)

def rec(n):
    if n==0:
        return 0
    if dp[n] < inf:
        return dp[n]
    
    res=rec(n-1) + abs(A[n] - A[n-1])
    if n>1:
        res=chmin(res,rec(n-2) + abs(A[n] - A[n-2]))
    dp[n]=res
    return res

print(rec(N-1))
def solve(n, H):
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(H[0] - H[1])
    for i in range(2, n):
        dp[i] = min(
            dp[i - 1] + abs(H[i] - H[i - 1]),
            dp[i - 2] + abs(H[i] - H[i - 2])
        )
    return dp[n - 1]

_n = int(input())
_H = list(map(int, input().split()))
print(solve(_n, _H))
inf = float("inf") 
n=int(input())
a=list(map(int ,input().split()))
dp=[inf]*n
k=2
dp[0]=0
for i in range(1,n):
   for j in range(i-1,max(0,i-k)-1,-1):
       dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]))
print(dp[n-1])
N=int(input())
h=list(map(int,input().split()))
ans=[0]*(N)
ans[0]=0
ans[1]=abs(h[1]-h[0])
if N>2 :
 for i in range(2,N):
  ans[i]=min(ans[i-2]+abs(h[i]-h[i-2]),ans[i-1]+abs(h[i]-h[i-1]))
print(ans[N-1])
n = int(input())
h = list(map(int, input().split()))

dp =[0, abs(h[1] - h[0])]

for i in range(2, n):
    dp += [min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]))]

print(dp[-1])
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
h = intl()

dp = [0]*n
for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[i] - h[0])
    else:
        dp[i] = min( abs(h[i]-h[i-1]) + dp[i-1], abs(h[i]-h[i-2]) + dp[i-2] )
print(dp[-1])
n=int(input())
l=[int(x) for x in input().split()]
d=[0]*n
if n-2>=0:
	d[-2]=abs(l[-2]-l[-1])

for i in range(n-3,-1,-1):
	mn=10**9
	mn=min(abs(l[i+1]-l[i])+d[i+1],mn)
	mn=min(abs(l[i+2]-l[i])+d[i+2],mn)
	d[i]=mn
print(d[0])
N = int(input())
*h, = map(int, input().split())

dp = [float('inf')] * N
dp[0] = 0

for i in range(1, N):
    if i == 1:
        dp[i] = abs(h[i] - h[i - 1])
    else:
        dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2])

print(dp[-1])
N = int(input())
h = list(map(int,input().split()))


dp = [float("inf")]*len(h)
dp[0] = 0


for i in range(1, len(h)):
    if(i == 1):
        dp[i] = h[i]
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))

print(dp[N-1])
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n

for i in range(1,n):
    if i == 1:
        dp[1] = abs(h[1]-h[0])
    else:
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))

print(dp[n-1])
import numpy as np


def main():
    n = int(input())
    h = np.fromstring(input(), dtype='int', sep=' ')
    h = np.append(h, [0] * 2)

    dp = np.full(n + 1, 10 ** 9, dtype='int')
    dp[0] = 0

    for i in range(n - 1):
        dp[i + 1:i + 3] = np.minimum(
            dp[i + 1:i + 3],
            dp[i] + np.abs(h[i] - h[i + 1:i + 3])
        )
    print(dp[n - 1])


if __name__ == "__main__":
    main()
n = int(input())
hlis = list(map(int, input().split()))
dp = [0] + [float('inf')]*n
dp[1] = dp[0] + abs(hlis[0])
for i in range(1, n):
    one = abs(hlis[i]-hlis[i-1])
    two = abs(hlis[i]-hlis[i-2])
    dp[i] = min(dp[i-1]+one, dp[i-2]+two)
print(dp[n-1])
N = int(input())
H = list(map(int,input().split()))
INF = 10**10
dp = [INF]*N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2,N):
  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(input())
H = list(map(int, input().split()))

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

for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))

print(dp[-1])