peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(n-1):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i<n-2:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[n-2])
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(n-2):
  dp[i+2]=min(dp[i]+abs(h[i+2]-h[i]),dp[i+1]+abs(h[i+2]-h[i]))
print(dp[n-1])
# A
# 若干解説を見た
# 2020/04/27  17:5-
n = int(input())
h = list(map(int, input().split()))

s = [0]*n
for i in range(1, n):
    if i == 1:
        s[i] = h[i] - h[i-1]
    else:
        s[i] = min(s[i-2] + abs(h[i]-h[i-2]), s[i-1] + abs(h[i]-h[i-1]))
        
print(s[-1])
n = int(input())
arr = list(map(int,input().split()))
dp=[arr[-1]]
som=0
i=n-1
while i!=0:
    op1 = abs(dp[-1]-arr[i-1])
    op2 = 10**18
    if i-2>=0:
        op2 = abs(dp[-1]-arr[i-2])
    minm = min(op1,op2)
    som+=minm
    if minm==op1:
        dp.append(arr[i-1])
        i-=1
    else:
        dp.append(arr[i-2])
        i-=2

print(som)
n=int(input())
l=list(map(int, input().split()))
inf=10**12
dp=[inf]*n
dp[0]=0
dp[1]=abs(l[0]-l[1])
for i in range(n-2):
	dp[i+2]=min(dp[i]+abs(l[i+2]-l[i]),dp[i+1]+abs(l[i+2]-l[i+1]))
print(dp)
print(dp[-1])
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 ** 4
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[N-1]
print(ans)
N = int(input())
h = list(map(int,input().split()))
cost = [1000000]*N
cost[0] = 0
for i in range(1, N):
  cost[i] = min((abs(h[i-1] - h[i]) + cost[i-1]),cost[i])
  if i >= 2:
    cost[i] = min((abs(h[i-2] - h[i]) + cost[i-2]), cost[i])
print(cost[-1])
#DP カエルの奴 A 　配るDP
N=int(input())

S=list(map(int,input().split()))
for i in range(100000):
    S.append(100000000)
DP=[100000000]*100010

DP[0]=0
for i in range(N):
    if DP[i]+abs(S[i]-S[i+1])<DP[i+1]:
        DP[i+1]=DP[i]+abs(S[i]-S[i+1])
    if DP[i]+abs(S[i]-S[i+2])<DP[i+2]:
        DP[i+2]=DP[i]+abs(S[i]-S[i+2])


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

INF = 10 ** 6
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[N-1])
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, *H = map(int, read().split())
dp = [INF] * N
dp[0] = 0

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

print(dp[N-1])
n=int(input())
A=list(map(int,input().split()))
sum=0
for i in range(n-2):
  a=abs(A[i]-A[i+1])
  b=abs(A[i]-A[i+2])
  sum+=min(a,b)
print(sum)
hight = [2, 9, 4, 5, 1, 6, 10]
lis = [0, hight[1]-hight[0]]

for i in range(len(hight)):
    if i == 0 or i == 1:
        pass
    else:
        lis.append(min(lis[i-2] + abs(hight[i]-hight[i-2]), lis[i-1] + abs(hight[i]-hight[i-1])))

print(lis)
def chmin(dp, i, target):
    if (dp[i] > target):
        dp[i] = target

n = int(input())
h = [i for i in input().split(" ")]
dp =[10**5] * n

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

print(dp[n - 1])
def chmin(dp, i, target):
    if (dp[i] > target):
        dp[i] = target

n = int(input())
h = [i for i in input().split(" ")]
dp =[100010] * n

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

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

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

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

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

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

DP = [10**10 for _ in range(N)]
DP[0] = 0
DP[1] = h[1]-h[0]

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)
print(DP[N-1])
N = int(input())
a = [int(x) for x in input().split()]
def dp(N,a):
    F = [0]*(len(a)+1)
    F[0]=0
    F[1]=0
    F[2]=abs(a[1]-a[0])
    if N == 1: return F[0]
    elif N == 2: return F[1]
    
    for n in range(2,N+1):
        F[n] = min(F[n-1] + abs(a[n-1]-a[n-2]),F[n-2]+abs(a[n-1]-a[n-3]))
    print(F)
    return F[-1] 
print(dp(N,a))
# coding:utf-8

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

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

print(dp[N-1])
N = int(input())
A = list(map(int, input().split()))
dp = [0 for _ in range(len(A))]
dp[0] = 0
for i in range(1,N):
 if i - 2>=0:
  dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]),dp[i-2] + abs(A[i] - A[i-2]))
else:
 dp[i] =dp[i-1] + abs(A[i] - A[i-1])
print(dp)
print(dp[len(A)-1])
# EDPC A Frog 1

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

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

for i in range(2,N):
    if cost[i] > cost[i-1]+abs(H[i]-H[i-1]):
        cost[i] = cost[i-1]+abs(H[i]-H[i-1])
    if cost[i] > cost[i-2]+abs(H[i]-H[i-2]):
        cost[i] = cost[i-2]+abs(H[i]-H[i-2])

print(cost[N-1])
INF = 10 ** 5 + 10

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

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] = chmin(DP[i], DP[i-1] + abs(H[i] - H[i-1]))
    DP[i] = chmin(DP[i], DP[i-2] + abs(H[i] - H[i-2]))
print(DP[-1])
N = int(input())
h = [0] + list(map(int, input().split()))

dp = [0] * (N+1)
for i in range(2, N+1):
    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[N])
import numpy as np

n = map(int, input())
h_list = [int(i) for i in input().split()]

dp = np.zeros((len(h_list)))
dp[1] = h_list[1]-h_list[0]

for i in range(2,len(h_list)):
    temp1 = dp[i-1] + abs(h_list[i] - h_list[i-1])
    temp2 = dp[i-2] + abs(h_list[i] - h_list[i-2])
    dp[i] = min(temp1, temp2)
    
    
print(dp[-1])
n=int(input())
l=list(map(int,input().split()))
dp=[0 for i in range(n)]

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

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

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

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

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

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

dp = [0]*(n+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 1000)

print(dp[n])
N=int(input())

L=list(map(int,input().split()))
S=[0]*100010
for i in range(N):
    S[i]=L[i]

DP=[10*12]*100010

DP[0]=0
for i in range(N):
    if DP[i+1]>DP[i]+abs(S[i+1]-S[i]):
        DP[i+1]=DP[i]+abs(S[i+1]-S[i])
    if DP[i+2]>DP[i]+abs(S[i+2]-S[i]):
        DP[i+2]=DP[i]+abs(S[i+2]-S[i])


print(DP[N-1])
N = int(input())
h = list(map(int, input().split()))
dp = [1000000] * 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])
import numpy as np
#N=int(input())
#h=list(map(int,input().split()))

N=4
h=[10,30,40,20]

dp=np.zeros(N)
print(dp)
dp[1]=abs(h[1]-h[0])
print(dp)

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

#total

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

dp = [10 ** 4] * 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[n-1])
n=int(input())
arr=list(map(int,input().split()))
prev2 = 0
if n > 1:
  prev1 = abs(arr[0]-arr[1])

for i in range(3, n+1):
    step_1 = abs(arr[i-1]-arr[i-2]) + prev1
    step_2 = abs(arr[i-1]-arr[i-3]) + prev2
    x = min(step_1, step_2)
    prev1 = step_2
    prev2 = x
   
print(prev2)
N = int(input())
h = list(map(int, input().split()))
# N = 6
# h = [30, 10, 60, 10, 60, 50]
dp = [0]*(N)
print("ini dp", dp)
for i in range(1, N):
    if i == 1:
        dp[1] = abs(h[1]-h[0])
        print("ini dp 1", dp)

    else:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
        print("ini dp 2", dp)

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

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

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

dp = []
dp.append(0)
dp.append(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.append(min(t1, t2))
def hoge():
  dp =[0] * (n + 1)
  dp[0] = 0
  dp[1] = abs(h_list[1] - h_list[0])
  for i in range(1, n):
    dp[i + 1] = min(dp[i - 2] + abs(h_list[i - 2] - h_list[i]), dp[i - 1] + abs(h_list[i - 1] - h_list[i]))
  return dp[n]

def solve():
  global n, h_list
  n = int(input())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()
N=int(input())
h=input().split()
i = N - 1
sum = 0
while i > 1:
    if abs(int(h[i]) - int(h[i-1])) < abs(int(h[i]) - int(h[i-2])):
        sum += abs(int(h[i]) - int(h[i-1]))
        i -= 1
    else:
        sum += abs(int(h[i]) - int(h[i-2]))
        i -= 2
if i == 1:
    sum += abs(int(h[1]) - int(h[0]))
print(sum)
n=int(input())
h=list(map(int,input().split()))
ans=0
temp=[0]*n
temp[0]=0
temp1=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())
k=2
l=list(map(int,input().split()))
ans=[0,abs(l[1]-l[0])]
for i in range(2,n):
    m=10**4+1
    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 = [int(i) for i in input().split()]
dp = [10**5 for _ in range(N)]
dp[0] = 0
for i in range(N-1):
    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[-1])
N = int(input())
footing = list(map(int, input().split()))

dp = [10 ** 6] * N
dp[0] = 0

# give
for i in range(N-1):
    if dp[i+1] > dp[i] + abs(footing[i+1] - footing[i]):
        dp[i+1] = dp[i] + abs(footing[i+1] - footing[i])

    if i < N-2:
        if dp[i+2] > dp[i] + abs(footing[i+2] - footing[i]):
            dp[i+2] = dp[i] + abs(footing[i+2] - footing[i])

print(dp[N-1])
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N = int(input())
H = [i for i in map(int,input().split())]
dp = [10**5 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    chmin(dp,dp[i-1]+abs(H[i]-H[i-1]),i)
    if i > 1:
        chmin(dp,dp[i-2]+abs(H[i]-H[i-2]),i)
print(dp[-1])
n=int(input())
rec=list(map(int,input().split()))
s=[rec[0],abs(rec[1]-rec[0])]
for i in range(2,n):
        total2=abs(rec[i]-rec[i-2])+s[i-2]
        total1=abs(rec[i]-rec[i-1])+s[i-1]
        s.append(min(total2,total1))
print(s[-1])
N = int(input())
h = list(map(int,input().split()))
A = [float('inf')] * (N)
A[0] = 0

for i in range(N-2):
    p = A[i] + abs(h[i+1] - h[i])
    q = A[i] + abs(h[i+2] - h[i])
    if  p < A[i+1]:
        A[i+1] = p
    if q < A[i+2]:
        A[i+2] = q
print(A[N-1])
N = int(input())
H = list(map(int,input().split()))



# DPテーブル
DP = [float('inf')]*N

# 初期条件
DP[0] = 0
DP[1] = abs(H[1] - H[0])

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

print(DP)
print(DP[N-1])
def solution(h):
    n = len(h)
    if n == 1:
        return 0
    elif n == 2:
        return abs(h[1]-h[0])
    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)
    return dp[n-1]

N = int(input())
h = list(map(int,input().split()))
res = solution(h)
print(res,end="")
N, *h = map( int, open(0).read().split())
D = [0] + [ abs( h[1] - h[0])]
k = 0
for i in range( 1, N - 1 ):
  k = min( D[ 0 ] + abs( h[ i + 1 ] - h[ i - 1 ]),
           D[ 1 ] + abs( h[ i + 1 ] - h[ i ]))
  D[ 0 ], D[ 1 ] = D[ 1 ], k
   
print( k )
N = int(input())
h = [int(x) for x in input().split()]

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

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

dp=[0 for i in range(n+1)]

for i in range(2,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])
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
h = [0] + list(map(int, input().split()))
dp = [10 ** 7] + [10 ** 7] * 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])
dp = [1001 for i in range(100002)]
n = int(input())
hs = list(map(int, input().split()))

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

print(dp[n-1])
n = int(input())
h = list(map(int,input().split()))
cost = [0]*n
for i in range(1,n):
    cost[i] = cost[i-1] + abs(h[i]-h[i-1])
    if i > 1:
        if cost[i] > cost[i-1] + abs(h[i]-h[i-2]):
            cost[i] = cost[i-2] + abs(h[i]-h[i-2])
print(cost[n-1])
n = int(input())
h = list(map(int, input().split()))
h.append(1000000007)
dp = [h[0]]
count = 0
while count < n - 1:
    sgst_1 = abs(h[count + 1] - h[count])
    sgst_2 = abs(h[count + 2] - h[count])
    if sgst_1 <= sgst_2:
        dp.append(sgst_1)
        count += 1
    else:
        dp.append(sgst_2)
        count += 2
print(dp[-1])
n = int(input())
h = list(map(int, input().split()))

dp = [10 ** 4] * 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])
import math

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

cost_list = [math.inf for _ in range(n)]

cost_list[0]=0
cost_list[1]=list_[1]-list_[0]

for i in range(2,n):
  one = cost_list[i-1] + abs(list_[i]-list_[i-1])
  two = cost_list[i-2] + abs(list_[i]-list_[i-2])
  
  cost_list[i]=min(one,two,)
  
print(cost_list[-1])
N = int(input())
h = list(map(int, input().split()))
a, b = 0, abs(h[-1] - h[-2])
for n in range(0, N - 2):
    a, b = b, min(b + abs(h[-(n + 3)] - h[-(n + 2)]),
                  a + abs(h[-(n + 3)] - h[-(n + 1)]))
print(a)
N = int(input())
h = list(map(int,input().split()))
DP = [10**9]*N
DP[0] = 0
#DP[1] = abs(h[1]-h[0])
DP[1] = min(DP[1],DP[0]+abs(h[0]-h[1]))
for i in range(N-2):
    DP[i+1] = min(DP[i+1],DP[i]+abs(h[i]-h[i+1]))    
    DP[i+2] = min(DP[i+2],DP[i]+abs(h[i]-h[i+2])) 
    
print(DP[-1])
N = int(input())
h = list(map(int, input().split()))

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

h_inf = 10 ** 5
dp = [h_inf] * 10 ** 6
dp[0] = 0
for i in range(10**6):
    h.append(10**5)

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

print(dp[N-1])
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 00:21:08 2020

@author: Kanaru Sato
"""

N = int(input())
h = list(map(int, input().split()))
memo = [100000000000]*N

#topdown
def cost(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1]-h[0])
    elif memo[n]:
        return memo[n]
    else:
        memo[n] = min(cost(n-2)+abs(h[n]-h[n-2]),cost(n-1)+abs(h[n]-h[n-1]))
        return memo[n]

print(cost(N-1))
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,*H = list(map(int,read().split()))
h = [0]
h.extend(H)
h.append(0)

dp = [100] * (n+5)
dp[1] = 0

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

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

dp=np.empty(N,dtype=int)
dp[0]=0

for i in range(1,N):
    a=10**5
    for j in range(1,min(K,i)+1):
        a=min(a,dp[i-j]+abs(H[i]-H[i-j]))
    dp[i]=a

print(dp[-1])
n = int(input())
 
pedras = list(map(int,input().split()))
 
dp = [0] * n
 
dp[0] = 0
dp[1] = abs(pedras[0] - pedras[1])
 
 
for i in range(2,n):
    custo1 = dp[i-1] + abs(pedras[i-1] - pedras[i])
    custo2 = dp[i-2] + abs(pedras[i-2] - pedras[i])
    dp[i] = min(custo1,custo2)
N=int(input())
h_array=input().split()
dp=[0]*N
def f(a,b):
    return abs(int(h_array[a])-int(h_array[b]))



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

dp = [10 ** 4 for i in range(n)]
dp[0] = 0
for i in range(n):
    if i <= n - 2:
        val1 = dp[i] + abs(h[i+1] - h[i])
        if val1 < dp[i+1]:
            dp[i+1] = val1
    if i <= n - 3:
        val2 = dp[i] + abs(h[i+2] - h[i])
        if val2 < dp[i+2]:
            dp[i+2] = val2
print(dp[-1])
n = int(input())
h = [int(i) for i in input().split()]

dp = [0,h[1]-h[0]]
for i in range(2,n):
    dp.append(min(dp[-2] + abs(h[i] - h[i-2]),dp[-1] + abs(h[i] - h[i-1])))
print(dp[n-1])
n = int(input())
h = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n - 1):
    dp[i] = max((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());
salto = [int(i) for i in input().split()];
 
Costo = [float('inf')]*(N - 2)+[0, abs(salto[1] - salto[0])]  ;
 
for i in range(2, N):
    Costo[i] = min(Costo[i - 2] + abs(salto[i] - salto[i - 2]), Costo[i - 1] + abs(salto[i] - salto[i - 1]));
 
print(Costo[N - 1]);
n = int(input())
hs = [int(c) for c in input().split()]
dp = [0] * n
dp[0] =  0
dp[1] = abs(hs[0] - hs[1])
for i in range(2, n):
  dp[i] = min(dp[i-1] + abs(hs[i-1] - hs[i]), dp[i-2] + abs(hs[i-2] - hs[i]))
  print(dp[-1])
INF = 10 ** 4 + 10

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

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] = chmin(DP[i], DP[i-1] + abs(H[i] - H[i-1]))
    DP[i] = chmin(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):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[0]))

print(dp[n-1])
N = int(input())
h = input().split()
h = [int(i) for i in h]
dp = [10**7] * 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[N-1])
def main():
	n = int(input())
	costs = list(map(int, input().split()))
	
	if n==1: return 0
	# each cur represents minimum cost needed to reach the step
	two_before = 0
	one_before = costs[1] - costs[0]
	for step in range(2, n):
		two_before, one_before = one_before, min(one_before + abs(costs[step] - costs[step-1]), two_before + abs(costs[step] - costs[step - 2]))
	return one_before

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

inf = 10**7
dp = [inf] * (n+1)
dp[1] = 0

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

print(dp[n])
N = int(input())
h = list(map(int, input().split()))
dp = [float('inf') for i in range(N)]

dp[0] = 0
dp[1] = 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-1]))

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

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

dp[0] = 0
dp[1] = 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()))

a = [0] * n
a[1] = abs(h[0] - h[1])
for i in range(2, n):
    w1 = a[i-1] + abs(h[i-1] - h[i])
    w2 = a[i-2] + abs(h[i-2] - a[i])
    a[i] = min(w1, w2)
print(a[n-1])
# n,k = map(int, input().split())
n = int(input())
h = list(map(int,input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = 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])
# dp[2] = min((h[2] - h[1])+dp[1], (h[2]-h[0])+dp[0])
# dp[3] = min((h[3] - h[2])+dp[2], (h[3]-h[1])+dp[1])
print(dp[-1])
N = int(input())
A = list(map(int, input().split()))

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

ans = [1000000] * N
ans[0] = 0
for i in range(N-1):
    ans[i+1] = min(ans[i+1], ans[i] + abs(h[i] - h[i+1]))
    if i + 2 > N - 1:
        continue
    ans[i+2] = min(ans[i+2], ans[i] + abs(h[i] - h[i+2]))
print(ans[-1])