peterverebics/CodeNet_Python_118 huggingface dataset:
inp = int(input())
if inp>=400 and inp<=599:
  print(8)
elif inp>=600 and inp<=799:
  print(7)
elif inp>=800 and inp<=999:
  print(6)
elif inp>=1000 and inp<=1199:
  print(5)
elif inp>=1200 and inp<=1399:
  print(4)
elif inp>=1400 and inp<=1599:
  print(3)
elif inp>=1600 and inp<=1799:
  print(2)
elif inp>=1800 and inp<=1999:
  print(1)
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

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

INF = 10**15

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

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

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

INF = float('inf')
dp = [INF] * 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+1)
dp[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]))

res = dp[N]
print(res)
def func(arr):
    crr=[0 for i in range(len(arr))]
    crr[0]=0
    crr[1]=abs(arr[1]-arr[0])
    for i in range(2,len(arr)):
        crr[i]=min(abs((arr[i]-arr[i-1]))+crr[i-1],abs((arr[i]-arr[i-2]))+crr[i-2])
    print(crr)
    
b=input()
cr=list(map(int,input().split()))
func(cr)
N=int(input())
A=list(map(int,input().split()))
dp=[float("INF")]*N
dp[0]=0
dp[1]=abs(A[0]-A[1])
for i in range(2,N):
  dp[i]=min(dp[i],abs(A[i]-A[i-1]),abs(A[i-2]-A[i]))
print(dp[-1])
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)
INF = 10**5
N = int(input())
height = list(map(int, input().split()))
cost = [INF]*N
cost[0] = 0
cost[1] = min(cost[1], cost[0]+abs(height[1]-height[0]))
for i in range(2, N):
  cost[i] = min(cost[i], cost[i-1]+abs(height[i]-height[i-1]), cost[i-2]+abs(height[i]-height[i-2]))
print(cost[N-1])
n = int(input())
h = list(map(int,input().split()))

dp = [10**8]*n

dp[0] = 0
dp[1] = abs(h[1] - h[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[-1])
N = int(input())
H = list(map(int, input().split()))
dp = [float('inf')] * 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])
                ) if i >= 2 else dp[i-1] + abs(H[i] - H[i-1])
print(*dp)
print(dp[N-1])
n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis={}
vis[0] = 0
vis[1] = 0
if n > 1:
  vis[2] = abs(arr[0]-arr[1])
if n == 2:
  print(vis[2])
for i in range(3, n+1):
    step_1 = abs(arr[i-1]-arr[i-2]) + vis[i-1]
    step_2 = abs(arr[i-1]-arr[i-3]) + vis[i-2]
    vis[i] = min(step_1, step_2)
   
print(vis[n])
n=int(input())
a=list(map(int,input().split()))
ans=0
i=n-1
while(i>1):
    k=min(abs(a[i-2]-a[i]),abs(a[i-1]-a[i]))
    ans+=k
    if abs(a[i-2]-a[i])<=abs(a[i-1]-a[i]):
        i-=2 
    else:
        i-=1
if i==1:
    ans+=abs(a[0]-a[1])
print(ans)
a = int(input())

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

dp = [1000000000]* len(hs)


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

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

print(dp[-1])
n = int(input())
arr = [int(i) for i in input().split()]
dp = [0 for i in range(n)]
print(dp)
for i in range(1,n):
    op1 = abs(arr[i]-arr[i-1]) + dp[i-1]
    op2 = abs(arr[i]-arr[i-2]) + dp[i-2] if i != 1 else float("inf")
    dp[i] = min(op1,op2)
print(dp[n-1])
n = int(input())
a = list(map(int, input().split()))

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

for i, v in enumerate(a):
  if i > n - 1:
    break
  if i - 2 < 0:
    dp[i] = abs(a[i] - a[i-1])
    continue
  one_step_cost = dp[i-1] + abs(a[i] - a[i-1])
  two_step_cost = dp[i-2] + abs(a[i] - a[i-2])
  dp[i] = min(one_step_cost, two_step_cost)
  

print(dp[-1])
dp = {}

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

dp[0] = 0
dp[1] = h[1] - h[0]

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

print(dp[n-1])
N=int(input())
h=list(map(int,input().split()))
i=0
s=0
while(i<N):
  d1=0
  d2=0
  if(i+1<N):
    d1=abs(h[i]-h[i+1])
  if(i+2<N):
    d2=abs(h[i]-h[i+2])
  if(d1<d2):
    s+=d1
    i+=1
  else:
    s+=d2
    i+=2
print(s)
n = int(input())
h = [i for i in map(int, input().split())]

f_inf = float('inf')
DP = [f_inf]*n
DP[0] = 0
DP[1] = h[1]-h[0]

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

print(DP[-1])
def chmin(a, b):
  if a > b:
    return b
  else:
    return a

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

if __name__ == '__main__':
  main()
n = int(input())
lis = list(map(int,input().split(' ')))
def sol(lis):
    if len(lis)<=2:
        return abs(lis[0]-lis[1])
    costs = [0,abs(lis[0]-lis[1])]
    for i in range(2,len(lis)):
        x = abs(lis[i]-lis[i-1])
        y = abs(lis[i]-lis[i-2])
        if x<y:
            costs.append(x+costs[-1])
        else:
            costs.append(y+costs[-2])
    return costs[-1]
print(sol(lis))
N = int(input())
Hs = list(map(int, input().split()))

dp = [2 ** 32] * (N + 1)
dp[0] = 0

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

dp = [0]+[100000]*(n-1)

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

S=list(map(int,input().split()))
for i in range(10):
    S.append(10**12)
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, = map(int, input().split())

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

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

print(dp)
N=int(input())
l=[int(x) for x in input().split()]
l1=[999999]*(N+1)
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])
import sys
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    h = list(IL())
    l = [1e5]*n
    l[0] = 0
    for i in range(1,n):
        l[i] = min(l[i],l[i-1]+abs(h[i-1]-h[i]))
        if 1<i:
            l[i] = min(l[i],l[i-2]+abs(h[i-2]-h[i]))
    print(l[n-1])
    return

if __name__=='__main__':
    Main()
n=int(input())
a=list(map(int,input().split()))
ans=0
i=0
while(i<n-2):
    k=min(abs(a[i+2]-a[i]),abs(a[i+1]-a[i])+abs(a[i+2]-a[i+1]))
    ans+=k
    if abs(a[i+2]-a[i])<=abs(a[i+1]-a[i])+abs(a[i+2]-a[i+1]):
        i+=2 
    else:
        i+=1 
if i==n-2:
    ans+=abs(a[n-1]-a[n-2])
print(ans)
def kodokBedindang(watu):
    if len(watu) == 1:
        return 0
    elif len(watu) == 2:
        return abs(watu[0]-watu[1])
    else:
        one = abs(watu[0] - watu[1])
        two = abs(watu[0] - watu[2])

        if two <= one:
            return two + kodokBedindang(watu[2::])
        else:
            return one + kodokBedindang(watu[1::])
#DP カエルの奴 A 　配るDP
N=int(input())
S=list(map(int,input().split()))
S.append(100010)
S.append(100010)
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])
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 12:16:43 2020

@author: PREET MODH
"""

input()
a=list(map(int,input().split()))
i=0
sum=0
a.append(10000000000)
while(i+2<len(a)):
    if i >=len(a):
        break
    b=a[i]
    store=min(a[i+1],a[i+2])
    diff=abs(b-store)
    sum=sum + diff
    if a[i+1]<a[i+2]:
        i=i+1
    else:
        i=i+2
print(sum)
n = int(input())
a = list(map(int, input().split()))
a.append(99999)
dp = [0] * (n+1)
dp[0] = 0

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

cost = [9999 for i in range(n)]
cost[:2] = 0, 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[-1])
n = int(input())
l = list(map(int, input().split()))
l1 = [0]*n
for i in range(1,n):
  l1[i] = min(l[i], abs(l[i]-l[i-1]))
print(l)
N = int(input())
H = list(map(int, input().split()))

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

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

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

dp = [1000000 for i in range(N)]
dp[0] = 0

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

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

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

INF = 10 ** 5 + 1
dp = [INF] * N
dp[0] = 0

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

print(dp[-1])
N = int(input())
h = list(map(int,input().split()))
cost = [1000000]*(N+10)
cost[0] = 0
for i in range(1, N):
  cost[i] = min(abs(h[i-1] - h[i]), cost[i])
  if i < N - 2:
    cost[i+1] = min(abs(h[i-1] - h[i+1]), cost[i+1])
print(cost[N-1])
def chmin(a, b):
  if a > b:
    return b
  else:
    return a

def main():
  dp = [1e4+10]*100010
  hs = [0]*100010
  N = int(input())
  hs[:N] = map(int, input().split())
  
  dp[0] = 0
  for i in range(N):
    dp[i+1] = chmin(dp[i+1], dp[i]+abs(hs[i+1]-hs[i]))
    dp[i+2] = chmin(dp[i+2], dp[i]+abs(hs[i+2]-hs[i]))
  print(dp[:N], dp[N-1])

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

dp=[10**5]*(N)
dp[0]=0
for i in range(1,N):
    dp[i]= min(dp[i-1]+abs(h[i]-h[i-1]),dp[i])
    if i > 1:
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])
import sys
sys.setrecursionlimit(10**7)

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

dp = [-1] * N # dp[i] := i から N-1 までの移動にかかる最小コスト
dp[N-1] = 0

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

dis = [0] * n
dis[1] = height[1] - height[0]
    
for i in range(2,n):
    dis[i] = min(dis[i-2] + abs(height[i] - height[i-2]), dis[i-1] + abs(height[i] - height[i-1]))

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

cost = [None for i in range(n)]
cost[:2] = 0, 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[-1])
n = int(input())
x =list(map(int,input().split()))
a = [0,abs(x[1]-x[0])]
if n>2:
    for i in range(2,n):
        a.append(min(abs(x[i]-x[i-2])+a[-2],abs(x[i]+x[i-1])+a[-1]))
else:
    print(a[-1])
    exit()
  
print(a[-1])
def main():
    n = int(input())
    hs = list(map(int, input().split()))

    INF = 10 ** 12
    dp = [INF] * n
    dp[0] = 0
    dp[1] = hs[1] - hs[0]

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

    print(dp[-1])


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

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

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

dp.append(dp[n-2] + abs(h[n-1]-h[n-2]))

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

INF = 10 ** 20

dp = [INF]*(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-2]))
 
print(dp[n-1])
N = int(input())
H = list(map(int, input().split()))

dp = [0] * (N+1)
dp[1] = H[0]

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

res = dp[N]
print(res)
def chmin(a, b):
    if a > b:
        a = b
        return a
    else:
        return a

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

dp = [100010] * n
dp[0] = 0

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

print(dp[n - 1])
n = int(input())
h = list(map(int,input().split()))
c = [0]*n
c[1]=abs(h[1]-h[0])
for i in range(2,n):
    c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1]))
print(h,c)
N=int(input())
h=list(map(int,input().split()))
# N = 4
# h = [10, 30, 40, 20]
dp = [1000000]*N
#d[i]はカエルが足場iへと移動するのに必要な最小コスト
dp[0]=0
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)
print("min cost=",dp[-1])
def find_min_cost(n, heights):
    if n == 1:
        return 0

    min_costs = [None] * n

    # Base case - First stone
    min_costs[0] = 0

    # Baze case - Second stone
    min_costs[1] = abs(heights[1] - heights[0])

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

    return min_costs[-1]
# 方針: 少ないコストの選択をbacktrack 
N = int(input())
h = [int(val) for val in input().split(' ')]
i = 1
total_cost = 0
while i < len(h):
    if i == len(h)-1:
        total_cost += abs(h[-i] - h[-i-1])
        break
    step1_cost = abs(h[-i] - h[-i-1]) 
    step2_cost = abs(h[-i] - h[-i-2]) 
    if step1_cost < step2_cost:
        total_cost += step1_cost
        i += 1
    else:
        total_cost += step2_cost
        i += 2
print(total_cost)
n=int(input())
arr=list(map(int,input().split()))
print(arr)
def frogOne(N, arr):
    dparr = [-1 for i in range(N)]
    dparr[0] = 0
    dparr[1] = abs(arr[0]-arr[1])
    for num in range(2, N):
        dparr[num] = min(dparr[num-2]+abs(arr[num-2]),
                         dparr[num-1]+abs(arr[num]-arr[num-1]))
    return dparr[-1]
# A - Frog1
import numpy as np

N = int(input())
h = list(map(int, input().split()))
dp = [10000000]*(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])
n = int(input())
h = list(map(int, input().split()))
INF = 10**8
dp = [INF]*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())
l = list(map(int, input().split()))
dp = [0 for i in range(n)]
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-1]))
print(dp[-1])
n = int(input())
h = list(map(int, input().split()))
h.append(99999999)
h.append(99999999)
dp = [999999] * (n + 2)
dp[0] = 0

for i in range(n):
    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())
his = list(map(int, input().split()))
dp = []
for i in range(n):
  dp.append(0)
for i in range(0, n):
  if i >= 2:
    dpm1 = abs(his[i] - his[i-1])
    dpm2 = abs(his[i] - his[i-2])
    if dpm1 <= dpm2:
      dp[i] = dp[i-1] + dpm1
    else:
      dp[i] = dp[i-2] + dpm2
  elif i == 0:
    pass
  else:
    dp[i] = abs(his[i] - his[i-1])
print(dp[n-1])
N=int(input())
H=list(map(int,input().split()))
dp=[float('inf')]*N
dp[0],dp[1]=0,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()))
dp = [0]*(n+1)
dp[0] = 0
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-1]))
print(dp[n-1])
n = int(input())
h = list(map(int,input().split()))
c = [0]*n
c[1]=abs(h[1]-h[0])
for i in range(1,n):
    c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1]))
print(c[n-1])
N = int(input())
H = list(map(int, input().split()))
INF = 10**4 + 1
minlist = [INF]*N
minlist[0] = 0
for i in range(N-2):
    minlist_i = minlist[i]
    minlist[i+1] = min(minlist[i+1], minlist_i + abs(H[i] - H[i+1]))
    minlist[i+2] = min(minlist[i+2], minlist_i + abs(H[i] - H[i+2]))
minlist[N-1] = min(minlist[N-1], minlist[N-2] + abs(H[N-1] - H[N-2]))
print(minlist[N-1])
N, *h = map( int, open(0).read().split())
D = [0] + [ abs( h[1] - h[0])]
k = [ abs( h[1] - h[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=list(map(int,input().split()))
DP=[0]*N
DP[0]=0
DP[1]=h[1]-h[0]-DP[0]
i=2
while i<N:
  DP[i]=min(abs(h[i]-h[i-1]-DP[i-1]),abs(h[i]-h[i-2]-DP[i-2]))
  i+=1
print(DP[-1])
# EDPC A Frog 1

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

cost = [0]*N
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)
print(cost[N-1])
def jumpCost(array):
    size = len(array)

    memo = [99999999999] * (size)

    memo[0] = 0

    for i in range(size):
        j = i+1

        while j < i + 2 + 1 and j < size:
            memo[j] = min(memo[j], memo[i] + abs(array[i] - array[j]))

            j += 1

    return memo[size - 1]


if __name__ == '__main__':
    n = int(input())

    a = list(map(int, input().rstrip().split()))
    jumpCost(a)
n = int(input())
h = list(map(int, input().split()))
dp = [0]
dp.append(abs(h[1]-h[0]))
print(dp)
if n > 2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]))
print(dp[-1])
n = int(input())
H = list(map(int, input().split()))
DP = [10 ** 5] * 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())
h = list(map(int, input().split()))
f = [1 << 20] * n 

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

print(f[n - 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] * N
dp[0] = 0

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

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

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

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

print(DP[-1])
def func(arr):
    crr=[0 for i in range(len(arr))]
    crr[0]=arr[0]
    crr[1]=arr[1]-arr[0]
    for i in range(2,len(arr)):
        crr[i]=min(abs((arr[i]-arr[i-1]))+crr[i-1],abs((arr[i]-arr[i-2]))+crr[i-2])
    print(crr[-1])
    
b=input()
cr=list(map(int,input().split()))
func(cr)
n = int(input())
h = list(map(int,input().split()))


dp = [99999999]*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-2]))
  
print(dp[n-1])
import numpy as np

N = int(input())
h = [0] + list(map(int, input().split()))

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

dp = [10**8]*n

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

S=list(map(int,input().split()))
for i in range(100010):
    S.append(1000000000)
DP=[100000000]*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])
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())]
  
  dp = [1e4+10]*100010
  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])

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

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

print(dp[-1])
n=int(input())
lis=list(map(int,input().split()))
num=0
j=0
while(j<len(lis)-1):
    m=0
    k=0
    m=abs(lis[j]-lis[j+1])
    if(j<len(lis)-2):
        k=abs(lis[j]-lis[j+2])
    else:
        k=1000000
    if(m<k):
        num=num+m
        j=j+1
    else:
        num=num+k
        j=j+2
print(num)
def chmin(target, index, value):
    if (target[index] > value):
        target[index] = value

n = int(input())
h = [i for i in input().split(" ")]
dp =[10000] * 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])
a = input()
hs = [int(x) for x in input().split()]

dp = [1000000000]* len(hs)

if len(hs) == 1:
  print(hs[0])
  exit()

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

if len(hs) == 2:
  print(dp[1])
  exit()

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

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

ans = [100000000] * 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])