peterverebics/CodeNet_Python_118 huggingface dataset:
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-1]-l[i]),dp[i-2]+abs(l[i-2]-l[i]))
print(dp[-1])
n, *h = map( int, open( 0 ).read().split() )

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

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

print(dp[-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(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i]- h[i-2])+dp[i-2])
    # print(dp)

print(dp[n-1])
N = int(input())
H = [int(i) for i in input().split()]

dp = [0] * (N+1)
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])
h=int(input())

def bupdp(l,h):
    dp=[0]*(h+1)
    dp[0] = 0
    for i in range(0,h):
        if i>1:
            dp[i] = min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]))
        if i==1:
            dp[i] = abs(l[i]-l[i-1])
        if i<1:
            dp[i] = 0   
    # print(dp)
    return dp[-2]

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

#dp[i]:i番目に到達するまでにはらうコストの最小値

dp = [0 for i in range(N)]
dp[0] = 0
dp[1] = abs(h[1]-h[0])

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

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

if N == 2:
  print(abs(h[1]-h[0]))
  exit()

dp = [0 for _ in range(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[N-1])
N = int(input())
h = list(map(int, input().split()))

opt = [0] * len(h)
opt[1] = abs(h[0]-h[1])

for i in range(2,len(h)):
    A = opt[i-1] + abs(h[i-1] - h[i])
    B = opt[i-2] + abs(h[i-2] - h[i])
    opt[i] = min(A, B)
print(opt[-1])
n=int(input())
a=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]))
    if i==1:
        continue
    dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]))
print(dp[-1])
n = int(input())
lst = list(map(int, input().split()))
cst = [float('inf')] * n

cst[0] = 0
for _ in range(0, n-2):
    cst[_+1] = min(cst[_] + abs(lst[_+1] - lst[_]),cst[_+1])
    cst[_+2] = min(cst[_] + abs(lst[_+2] - lst[_]),cst[_+2])
cst[n-1] = min(cst[n-2] + abs(lst[n-1] - lst[n-2]),cst[n-1])
print(cst[n-1])
inf = 10**9

def main():
  N = int(input())
  h = list(map(int,input().split()))
  memo = [inf]*N
  memo[0] = 0
  
  def calcCost(start,goal,h):
    return abs(h[goal]-h[start])
  
  for i in range(1,N):
    memo[i] = min(memo[i],memo[i-1]+calcCost(i-1,i,h))
    if i > 1:
      memo[i] = min(memo[i],memo[i-2]+calcCost(i-2,i,h))
  print(memo[-1])

main()
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[n-1])
def getval():
    n = int(input())
    h = list(map(int,input().split()))
    return n,h 

def main(n,h):
    dp = [0,abs(h[1]-h[0])]
    for i in range(1,n-1):
        x = dp[-1]+abs(h[i+1]-h[i])
        y = dp[-2]+abs(h[i+1]-h[i-1])
        dp.append(min(x,y))
    print(dp[-1])
        
if __name__=="__main__":
    n,h = getval()
    main(n,h)
n = int(input())
h = list(map(int, input().split()))
dp = [None]*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()))
h1=abs(h[0]-h[1])
h0=0
for i in range(1,N-1):
    h0,h1=h1,min(
    abs(h[i+1]-h[i-1])+h0,
    abs(h[i+1]-h[i])+h1
    )
print(h1)
n=int(input())
h=list(map(int,input().split()))

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

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

cost_list = [0] * len(h_list)

cost_list[0] = 0
cost_list[1] = abs(h_list[1] - h_list[0])

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

print(cost_list[-1])
def rec(a):
    dp=[0]*len(a)
    for i in range(len(a)):
        if i==0:
            dp[i]=0
        elif i==1:
            dp[i]=abs(a[i]-a[i-1])
        else:
            dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2])
    return dp[len(a)-1]
n=int(input())
a=[int(i) for i in input().split()]
print(rec(a))
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

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

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
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 > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

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

dp = [0]

for i, x in enumerate(H):
  if i == 0:
    continue
  elif i == 1:
    dp.append( abs(H[i] - H[i-1]) )
  else:
    dp.append( min( dp[i-2] + abs(H[i] - H[i-2]) , dp[i-1] + abs(H[i] - H[i-1]) ) )

print(dp[-1])
def input_li():
    return list(map(int, input().split()))

def input_int():
    return int(input())

N = input_int()
h_li = input_li()
dp = [0] * N
dp[0] = 0
dp[1] = abs(h_li[1] - h_li[0])
for i in range(2, N):
    dp[i] = min(
        dp[i - 1] + abs(h_li[i] - h_li[i - 1]),
        dp[i - 2] + abs(h_li[i] - h_li[i - 2])
    )
print(dp[-1])
n = int(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[0] - H[i])
    else:
        dp[i] = min(
            dp[i - 2] + abs(H[i - 2] - H[i]),
            dp[i - 1] + abs(H[i - 1] - H[i])
            )

print(dp[-1])
def solve(h):
	best_p = abs(h[0] - h[1])
	best_pp = 0
	n = 2
	while n < len(h):
		cost1 = best_p + abs(h[n] - h[n-1])
		cost2 = best_pp + abs(h[n] - h[n-2])
		best = min(cost1, cost2)
		best_pp, best_p = best_p, best
		n = n + 1
	return best_p


def main():
	N = int(input())
	heights = list(map(int, input().split()))
	assert len(heights) == N
	assert N >= 2
	res = solve(heights)
	print(res)


if __name__ == '__main__':
	main()
n = int(input())
h = list(map(int, input().split()))
dp = [float("Inf")] * (n + 1)

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[n - 1])
from math import inf

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

costs = [inf]*n
costs[0] = 0

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

INF = sys.maxsize

N = int(input().strip())
h = [int(x) for x in input().split()]

memo = [INF] * N

for i in range(N - 1, -1, -1):
  if i == N -1:
    memo[i] = 0
  else:
    memo[i] = min(
      memo[i + 1] + abs(h[i] - h[i + 1]) if i + 1 < N else INF,
      memo[i + 2] + abs(h[i] - h[i + 2]) if i + 2 < N else INF                        
    )
  
print(memo[0])
n = int(input())
h = list(map(int, input().split()))
dp = [10 ** 18 for _ in range(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[-1])
n=int(input())
h=list(map(int,input().split()))
li=[0]*n
li[1]=abs(h[1]-h[0])
for i in range(2,n):
    li[i]=min(li[i-1]+abs(h[i]-h[i-1]),li[i-2]+abs(h[i]-h[i-2]))
##print(li)
print(li[n-1])
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())
cst=list(map(int,input().split()))
arr=[0]*10**5
arr[0]=0
arr[1]=abs(cst[1]-cst[0])
if n==2:
    print(arr[1])
else:
    for i in range(2, n):
        arr[i] = min(abs(cst[i - 1] - cst[i]) + arr[i - 1], abs(cst[i - 2] - cst[i]) + arr[i - 2])
    print(arr[i])
#Educational DP Contest
#A-Frog1

n = int(input())
#n,m = map(int,input().split())
lst1 = list(map(int,input().split()))

#dp table
dp = [0]*n


#process1
dp[1] = abs(lst1[1]-lst1[0])

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

#output process
print(dp[-1])
input()
a = list(map(int, input().split()))
dp = [float('inf')]*len(a)
dp[0] = 0
for i in range(len(a)-1):
    dp[i+1] = min(dp[i+1], dp[i] + abs(a[i+1] - a[i]))
    if i < len(a)-2:
        dp[i+2] = dp[i] + abs(a[i+2] - a[i])
print(dp[-1])
n = int(input())
lis = list(map(int, input().split()))
dp = []
for k in range(n+1):
    dp.append(0)

for i in range(2, n+1):
    if i == 2:
        dp[i] = abs(lis[i-1]-lis[i-2])
        #print(i, dp[i])
    else:
        #print(i)
        dp[i] = min(abs(lis[i-1]-lis[i-2])+dp[i-1], abs(lis[i-1]-lis[i-3])+dp[i-2])
        #print(i, dp[i])
print(dp[n])
def chmin(a,b):
    if a>b: a = b
    return a
def chmax(a,b):
    if a<b: a = b
    return a
N = int(input())
h = list(map(int,input().rstrip().split(' ')))
dp = [float('INF')]*N
dp[0] = 0
for i in range(1,N):
    dp[i] = chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]))#1個前から移動
    if i>1 : dp[i] = chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]))#2個前から移動
print(dp[-1])
n = int(input())
h = list(map(int,input().split()))
dp = [int(1e+10) for _ in range(n)]
dp[0],dp[1] = 0,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 = [float('inf')]*n
dp[0] = 0
for i in range(n):
    if i+1 < n:
        dp[i+1] = min(dp[i+1], abs(h[i] - h[i+1]) + dp[i]) 
    if i+2 < n:
        dp[i+2] = min(dp[i+2], abs(h[i] - h[i+2]) + dp[i])
print(dp[-1])
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n
for i in range(n):
    if i == 0:
        continue
    if i == 1:
        dp[1] = abs(h[0] - h[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[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(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])

print(dp[N-1])
# Educational_DP_A_Frogs.py

N = int(input())
H = list(map(int, input().split()))
# dp[i]:カエルがiに行くまでのコスト最小値
# dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]), dp[i-1]+abs(H[i]-H[i-1]))

dp = [0 for i 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)
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 - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))

print(dp[N - 1])
INF = float('inf')
n = int(input())
h = [int(i) for i in input().split()]
dp = [0, abs(h[1] - h[0])]
for i in range(2, n):
    dp += [min(dp[-1] + abs(h[i] - h[i - 1]), dp[-2] + abs(h[i] - h[i - 2]))]
print(dp[-1])
#Frog1
n=int(input())
h=list(map(int,input().split()))
Min=0
dp={}
for val in range(n):
    if(val==0):
        dp[val]=0
    if(val==1):
        dp[val]=abs(h[0]-h[1])
    elif(val>=2):
        dp[val]=min(abs(h[val]-h[val-1])+dp[val-1],abs(h[val]-h[val-2])+dp[val-2])
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])
# A - Frog1
import numpy as np

N = int(input())
h = list(map(int, input().split()))
dp = [10**9]*(N+2)
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])
import sys
input = sys.stdin.readline
import numpy as np

N = int(input())
hight_list = np.array([int(item) for item in input().split()])

dp = np.full(N, hight_list.sum(), dtype='int64')
dp[0] = 0
dp[1] = abs(hight_list[1] - hight_list[0])

for i in range(2, N):
    cost1 = abs(hight_list[i-1] - hight_list[i])
    cost2 = abs(hight_list[i-2] - hight_list[i])
    dp[i] = min(dp[i-1] + cost1, dp[i-2] + cost2)
    # print(dp)

print(dp[N-1])
n = int(input())
h = [int(i) for i in input().split()]
dp = [10 ** 5 for _ in range(n)]
dp[0] = 0

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

f = sys.stdin.buffer
n = int(f.readline())
h = list(map(int, f.readline().split()))
p0, p1 = 0, abs(h[1] - h[0])
for i in range(2, n):
    p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))
    p0, p1 = p1, p2
print(p1)
import math
n = int(input())
arr = [int(x) for x in input().split()]

dp = [0]*n
for i in range(n):
    if i>=2:
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i-2]-arr[i]))
    elif i==1:
        dp[i] = abs(arr[i]-arr[i-1])
    else:
        dp[i] = 0
print(dp[n-1])
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-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()))

dp = [0]*N

for i in range(N):
  if i == 0:
    dp[0] = 0
    continue
  if i == 1:
    dp[1] = abs(h[1]-h[0])
    continue
    
  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])
def solve():
  n = int(input())
  cost = list(map(int, input().split(' ')))
  dp = [-1 for _ in range(n)]
  dp[0] = 0
  dp[1] = abs(cost[1] - cost[0])
  for i in range(2, n):
    dp[i] = min(dp[i-2] + abs(cost[i] - cost[i-2]), 
                dp[i-1] + abs(cost[i] - cost[i-1]))
  print(dp[-1])
  
  
solve()
def solve(h):
    dp = [0, abs(h[0]-h[1])]
    for i in range(2, len(h)):
        one = dp[i-1] + abs(h[i-1]-h[i])
        two = dp[i-2] + abs(h[i-2]-h[i])
        dp.append(min(one, two))
    return dp[-1]



if __name__ == "__main__":
    n = int(input())
    h = [int(x) for x in input().split()]
    print(solve(h))
import sys
input = sys.stdin.readline

n = int(input())
h = [int(x) for x in input().split()]

dp = [float('inf')] * (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[-1])
N = int(input())
h = input().split()
h = [int(i) for i in h]
dp = [0] * N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(1, N-1):
    dp[i+1] = min(dp[i] + abs(h[i]-h[i+1]), dp[i-1] + abs(h[i-1]-h[i+1]))
print(dp[N-1])
import numpy as np
N = int(input())
h = list(map(int, input().split()))


memo = np.full(N, 10**4)
memo[0] = 0
memo[1] = abs(h[0] - h[1])
for i in range(2, N):
    memo[i] = min([memo[i-1] + abs(h[i-1] - h[i]), memo[i-2] + abs(h[i-2] - h[i])])
print(memo[N-1])
n = int(input())
h = [int(x) for x in input().split()]
h.insert(0, -1)
dp = [-1] * (n+1)
dp[1] = 0
dp[2] = abs(h[1] - h[2])

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

print(dp[n])
II = lambda: int(input())
SI = lambda: input()
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
n = II()
a = LI()
d = [0]*n
d[1] = abs(a[1]-a[0])
for i in range(2,n):
	d[i] = min(d[i-1]+abs(a[i-1]-a[i]),d[i-2]+abs(a[i-2]-a[i]))
print(d[-1])
n = int(input())
hn = list(map(int, input().split()))
dp = [float('inf') for _ in range(n)]
dp[0] = 0
dp[1] = abs(hn[1] - hn[0])
for i in range(2, n):
    dp[i] = min(
        dp[i],
        dp[i-1] + abs(hn[i-1] - hn[i]),
        dp[i-2] + abs(hn[i-2] - hn[i])
        )
print(dp[n-1])
n = int(input())
h = list(map(int,input().split()))
dp = [10**4] * (n+1)
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-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))
# print(dp)
print(dp[n-1])
n = int(input())
n_list = list(map(int, input().split()))
dp = [-1]*n
dp[0] = 0
dp[1] = abs(n_list[1]-n_list[0])

for i in range(2,n):
  dp[i] = min(abs(n_list[i]-n_list[i-1])+dp[i-1], abs(n_list[i]-n_list[i-2])+dp[i-2])
print(dp[n-1])
n = int(input())
li = [int(x) for x in input().split()]

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

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

print('{}'.format(dp[n-1]))
INF = 10e5
n = int(input())
h = list(map(int,input().split()))
dp = [INF for _ in range(n)]

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

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

print(dp[n-1])
n=int(input())
import sys
sys.setrecursionlimit(10 ** 6)
h=list(map(int,input().split()))
cos={0:0,1:abs(h[1]-h[0])}
def cost(x):
  if x not in cos:
    d1=cost(x-1)+abs(h[x]-h[x-1])
    d2=cost(x-2)+abs(h[x]-h[x-2])
    cos[x]=min(d1,d2)
    return cos[x]
  else:
    return cos[x]
  
print(cost(n-1))
n = int(input())
a = list(map(int, input().split()))
dp = [0]*n
for i in range(n):
  if i == 0:
    pass
  elif i == 1:
    dp[i] = abs(a[i]-a[i-1]) + dp[i-1]
  else:
    dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[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(N-2):
  dp[i+2]=min(dp[i+1]+abs(H[i+2]-H[i+1]),dp[i]+abs(H[i+2]-H[i]))

print(str(dp[N-1]))
import sys
import io


def main():
    f = sys.stdin.buffer
    n = int(f.readline())
    h = list(map(int, f.readline().split()))
    p0, p1 = 0, abs(h[1] - h[0])
    for i in range(2, n):
        p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))
        p0 = p1
        p1 = p2
    print(p1)


if __name__ == "__main__":
    main()
n = int(input())
h = list(map(int,input().split()))

dp=[10**10]*(n+2)

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

for i in range(3,n+1):
  dp[i]=min(dp[i],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())
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]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1])))

print(dp[-1])
N=int(input())
h=list(map(int,input().split()))
DP=[0]*N
DP[0]=0
DP[1]=abs(h[0]-h[1])
for i in range(1,N-1):
  DP[i+1]=min(DP[i]+abs(h[i]-h[i+1]),DP[i-1]+abs(h[i-1]-h[i+1]))
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(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, = map(int, input().split())
dp = [0] * N
for i in range(1, N):
    if i == 1:
        dp[i] = dp[i-1] + 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(input())
h=list(map(int,input().split()))
dp=[0]
cost=[]
for i in range(1,N):
    cost=[]
    cost.append(abs(h[i]-h[i-1])+dp[i-1])
    if i>=2:
        cost.append(abs(h[i]-h[i-2])+dp[i-2])
    dp.append(min(cost))
print(dp[N-1])
def chmin(a, b):
  if a > b:
    return b
  return a

def main():
  N = int(input())
  hs = [i for i in map(int, input().split())]
  
  INF = 1e12
  dp = [INF]*N
  dp[0] = 0
  for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(hs[i]-hs[i-1]))
    if i > 1:
      dp[i] = chmin(dp[i], dp[i-2] + abs(hs[i]-hs[i-2]))
  print(dp[N-1])
  return

if __name__ == '__main__':
  main()
def main():
    N = int(input())
    H = list(map(int, input().split()))
    dp = [float('inf')] * (N + 5)
    dp[0] = 0
    for i in range(N):
        if i + 1 <= N - 1:
            dp[i+1] = min(dp[i+1], dp[i] + abs(H[i+1] - H[i]))
        if i + 2 <= N - 1:
            dp[i+2] = min(dp[i+2], dp[i] + abs(H[i+2] - H[i]))
    
    print(dp[N-1])

    

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

tmp = [int(1e9)] * (N+10)
tmp[0] = 0
tmp[1] = abs(h[1] - h[0])
for i in range(2, N):
    tmp[i] = min(tmp[i-2]+abs(h[i]-h[i-2]), tmp[i-1]+abs(h[i]-h[i-1]))


print(tmp[N-1])
# DP practice
# https://atcoder.jp/contests/dp/tasks/dp_a

# 入力方法としてはこれが手軽
N = int(input())
h = list(map(int, input().split()))

dp = list()

# N = 0, 1 の時の処理も必要。だが省く
dp.append(0)
dp.append(dp[0] + abs(h[1] - h[0]))

for i in range(2, N):
	dp.append(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()))

ml = [10**9]* N

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

print(ml[N-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):
    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])
import math

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * (10**5 + 10)

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

dp[0] = 0 #初期値 = 0
for i in range(N-1):
    dp[i+1] = chmin(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    if i < N-2:
        dp[i+2] = chmin(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
print(dp[N-1])
import sys
n=int(input())
k=2
l=list(map(int,input().split()))
ans=[0,abs(l[1]-l[0])]
for i in range(2,n):
    m=sys.maxsize
    c=1
    while c<min(k+1,i+1):
        
        m=min(abs(l[i]-l[i-c])+ans[-c],m)
        c+=1
    ans.append(m)
# print(ans)
print(ans[-1])
N = int(input())
h = list(map(int,input().split()))
dp = [0] * (N + 1)

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])
import math
def better(l, ans):
    for i in range(2, n):
        ans[i] = min(ans[i - 1] + abs(l[i]-l[i - 1]), ans[i - 2] + abs(l[i]-l[i - 2]))
    return ans
n = int(input())
l = list(map(int, input().split()))
ans = [0] * n
ans[1] = abs(l[1]-l[0])
print(better(l, ans)[len(ans)-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])
n = int(input())
h = list(map(int,input().split()))
dp = [0]*n
for i in range(1,n):
    dp_0 = dp[i-1] + abs(h[i]-h[i-1])
    if i -2 < 0:
        dp_1 = 10**10
    else:
        dp_1 = dp[i-2] + abs(h[i]-h[i-2])
    dp[i] = min(dp_0,dp_1)
print(dp[-1])