CodeEff/ECCO huggingface dataset:
# Original solution

import itertools
result = 10 ** 15
N = int(eval(input()))

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

numbers = []
for i in range(N):
    numbers.append(1)
    numbers.append(2)
combination = list(dict.fromkeys([seq for i in range(len(numbers), 0, -1) for seq in itertools.combinations(numbers, i) if sum(seq) == N - 1]))
for i in range(len(combination)):
    idouti = 0
    for j in range(len(combination[i]) + 1):
        if j == 0:
            #idouti += abs(h[0] - h[combination[i][j]])
            continue
        a = sum(combination[i][0:j])

        b = sum(combination[i][0:j - 1])

        idouti += abs(h[a] - h[b])
    if result > idouti:
        result = idouti

print(result)


# Optimized solution
N = int(eval(input()))
h = [int(x) for x in input().split()]
dp = []
dp1 = 0
dp2 = 0
for i in range(N):
    if i == 0:
        dp.append(0)
        continue

    if i == 1:
        dp.append(abs(h[0] - h[1]))
        continue

    dp1 = dp[i - 1] + abs(h[i] - h[i - 1])
    dp2 = dp[i - 2] + abs(h[i] - h[i - 2])

    if dp1 < dp2:
        dp.append(dp1)
    else:
        dp.append(dp2)
print((dp[-1]))
# Original solution
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
h = list(li())

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

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

# Optimized solution
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
h = list(li())

dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(1,n-1):
    dp[i+1] = min(dp[i-1] + abs(h[i+1]-h[i-1]),
                  dp[i] + abs(h[i+1]-h[i]))
    
print((dp[-1]))
# Original solution
def LI(): return list(map(int, input().split()))

n = int(eval(input()))
h = LI()

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


# Optimized solution
def LI(): return list(map(int, input().split()))

n = int(eval(input()))
h = LI()

dp = [0] * n
dp[0], dp[1] = 0, 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('i', i, '1step', abs(h[i+1] - h[i]), 'dp1', dp[i+1], '2step', abs(h[i+2] - h[i]), 'dp', dp[i], 'dp2', dp[i+2])

print((dp[-1]))
# print(dp)
# Original solution
N = int(eval(input()))
stones = list(map(int,input().split()))

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


# Optimized solution
N = int(eval(input()))
X = list(map(int,input().split()))

dp = [0,abs(X[1] - X[0])]
for x in range(2,N):
  dp.append(min(dp[x-1] + abs(X[x-1]-X[x]),
                dp[x-2] + abs(X[x-2]-X[x])
               )
           )
print((dp[N-1]))
# Original solution
n = int(eval(input()))
arr = list(map(int, input().split()))

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

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

print((dp[-1]))

# Optimized solution

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

if t == 1:
    print((0))
elif t == 2:
    print((abs(a[0] - a[1])))

else:
    dp = [-1] * (t)
    dp[0] = 0
    dp[1] = abs(a[0] - a[1])
    for i in range(2, t):
        dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1],
                    abs(a[i] - a[i - 2]) + dp[i - 2])

    print((dp[t - 1]))
# Original solution

# ########## ------ Import ------- ##########

import sys
import math
from collections import Counter
from collections import deque as deq
from functools import lru_cache

# ########## ------ Define -------- #########

INT_MAX = float("inf")
INT_MIN = float("-inf")

# ########## ------ Input Functions ---- #########

input = sys.stdin.readline


def inp():
    return(int(eval(input())))


def inlt():
    return(list(map(int, input().split())))


def insr():
    s = eval(input())
    return(list(s[:len(s) - 1]))


def invr():
    return(list(map(int, input().split())))


# ########## ------ Code ------- ##########
def go(i):
    if i == 0:
        dp[i] = 0
        return dp[i]
    if i == 1:
        dp[i] = abs(a[0] - a[i])
        return dp[i]

    if dp[i] != -1:
        return dp[i]

    dp[i] = min(abs(a[i] - a[i - 1]) + go(i - 1),
                abs(a[i] - a[i - 2]) + go(i - 2))
    return dp[i]


t = inp()
a = inlt()

if t == 1:
    print((0))
elif t == 2:
    print((abs(a[0] - a[1])))

else:
    dp=[-1]*t
    dp[0] = 0
    dp[1] = abs(a[0] - a[1])
    for i in range(2, t):
        dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1],
                    abs(a[i] - a[i - 2]) + dp[i - 2])


    print((dp[t - 1]))


# Optimized solution

# ########## ------ Import ------- ##########

import sys
import math
from collections import Counter
from collections import deque as deq
from functools import lru_cache

# ########## ------ Define -------- #########

INT_MAX = float("inf")
INT_MIN = float("-inf")

# ########## ------ Input Functions ---- #########

input = sys.stdin.readline


def inp():
    return(int(eval(input())))


def inlt():
    return(list(map(int, input().split())))


def insr():
    s = eval(input())
    return(list(s[:len(s) - 1]))


def invr():
    return(list(map(int, input().split())))


# ########## ------ Code ------- ##########
t = inp()
a = inlt()

if t == 1:
    print((0))
elif t == 2:
    print((abs(a[0] - a[1])))

else:
    dp=[-1]*t
    dp[0] = 0
    dp[1] = abs(a[0] - a[1])
    for i in range(2, t):
        dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1],
                    abs(a[i] - a[i - 2]) + dp[i - 2])


    print((dp[t - 1]))
# Original solution
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [float('inf')]*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[N-1]))

# Optimized solution
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [float('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[N-1]))
# Original solution
if __name__=='__main__':
    N = int(eval(input()))
    hi = [int(i) for i in input().split()]
    dp = [0 for i in range(N)]
    dp[1] = abs(hi[0]-hi[1])
    
    for i in range(2,N):
        dp_1 = dp[i-1] + abs(hi[i]-hi[i-1])
        dp_2 = dp[i-2] + abs(hi[i]-hi[i-2])
        dp[i] = min(dp_1,dp_2)
            
    print((dp[N-1]))

# Optimized solution
if __name__=='__main__':
    N = int(eval(input()))
    hi = list(map(int,input().split()))
    dp = [0]*N
    dp[1] = abs(hi[0]-hi[1])
    
    for i in range(2,N):
        dp_1 = dp[i-1] + abs(hi[i]-hi[i-1])
        dp_2 = dp[i-2] + abs(hi[i]-hi[i-2])
        dp[i] = dp_1 if dp_1 < dp_2 else dp_2
            
    print((dp[-1]))
# Original solution
def ch_min(a, b):
    if (a > b):
        a = b
    return a


if __name__ == "__main__":
    N = int(eval(input()))
    h = list(map(int, input().split()))
    INF = 10 ** 10
    dp = [INF] * 100010
    dp[0] = 0
    for i in range(N - 1):
        dp[i + 1] = ch_min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        if (i < N - 2):
            dp[i + 2] = ch_min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
    print((dp[N - 1]))


# Optimized solution
N = int(eval(input()))
h = list(map(int, input().split()))
x = [0] * N
x[1] = x[0] + abs(h[1] - h[0])
for i in range(2, N):
    x[i] = min(x[i - 1] + abs(h[i] - h[i - 1]),
               x[i - 2] + abs(h[i] - h[i - 2]))
print((x[N-1]))
# Original solution
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: list(map(int, sys.stdin.readline().split()))
nms = lambda: list(map(str, sys.stdin.readline().split()))
nl = lambda: list(nm())

n = ni()
h = nl()
INF = 10 ** 9
dp = [INF for i in range(n)]
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    for j in h:
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[-1]))

# Optimized solution
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: list(map(int, sys.stdin.readline().split()))
nms = lambda: list(map(str, sys.stdin.readline().split()))
nl = lambda: list(nm())

n = ni()
h = nl()
INF = 10 ** 9
dp = [INF for i in range(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]))
print((dp[-1]))
# Original solution
N = int(eval(input()))
[*h] = list(map(int, input().split()))
dp = [float('inf') for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2, N):
    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-1]))

# Optimized solution
N = int(eval(input()))
[*h] = list(map(int, input().split()))
dp = [float('inf') for _ in range(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]))

print((dp[N-1]))
# Original solution
N = int(eval(input()))
[*h] = list(map(int, input().split()))
dp = [float('inf') for _ in range(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]))

print((dp[N-1]))

# Optimized solution
N = int(eval(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-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
 
print((dp[N-1]))
# Original solution
n = int(eval(input()))
h = list(map(int, input().split()))

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

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

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))

dp = [float('inf')]*n
dp[0] = 0
dp[1] = dp[0]+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]))
  
print((dp[-1]))
# Original solution
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 00:21:08 2020

@author: Kanaru Sato
"""
import sys
sys.setrecursionlimit(10 ** 6)

N = int(eval(input()))
h = list(map(int, input().split()))
memo = [-1]*N
memo[0] = 0
memo[1] = abs(h[1]-h[0])

#topdown
def cost(n):
    if n <= 1 or memo[n] >= 0:
        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)))

# Optimized solution
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 18:45:39 2020

@author: Kanaru Sato
"""

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

dp = [-1]*n

for i in range(n):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = 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]))
# Original solution
n = int(eval(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]))

# Optimized solution
import sys
input = sys.stdin.readline
n = int(eval(input()))
h = tuple(map(int,input().split()))

dp = [0]*n
#print(dp)

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

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)

print((dp[-1]))
# Original solution
N = int(eval(input()))
H_ = list(map(int,input().split()))
def dp_solver(x):#x番の足場に行くための最小コスト
    H = H_
    dp = [0]*len(H)
    dp[1] = abs(H[0]-H[1])
    for i in range(len(H)-2):
        dp[i+2] = min(dp[i]+abs(H[i+2]-H[i]),dp[i+1]+abs(H[i+2]-H[i+1]))
    return dp[x]
    
print((dp_solver(N-1)))

# Optimized solution
N = int(eval(input()))
H_ = list(map(int,input().split()))
def dp_solver(x):
    H = H_
    dp=[float('inf')]*N
    dp[0]=0
    dp[1]=abs(H[1]-H[0])
    for i in range(N-2):
        dp[i+2] = min(dp[i+2],dp[i]+abs(H[i+2]-H[i]))
        dp[i+2] = min(dp[i+2],dp[i+1]+abs(H[i+2]-H[i+1]))
    return dp[x-1]
print((dp_solver(N)))
# Original solution
# coding: utf-8
N=int(eval(input()))
H=list(map(int,input().split()))
def dp(L):
    dp=[0]*N
    dp[1]=abs(L[1]-L[0])
    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]))
    return dp[N-1]
    
print((dp(H)))

# Optimized solution
# coding: utf-8
n = int(eval(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]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print((dp[n-1]))
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))

dp = [0]*N

for i, x in enumerate(H):
  if i == 0:
    continue
  elif 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]))

# Optimized solution
N = int(eval(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]))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
#コストの配列 全部無限にしておく
cost = [float("inf") for _ in range(N)]
cost[0] = 0
for i in range(N-1):
    cost[i + 1] = min(cost[i + 1], cost[i] + abs(A[i+1] - A[i]))
    if(i + 2 < N):
        cost[i + 2] = min(cost[i+2], cost[i] + abs(A[i+2] - A[i]))
print((cost[N-1]))

# Optimized solution
N = int(eval(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]))
# Original solution
def flog(heights,n):
    #height:足場の高さのリスト
    #n:heightsの長さ
    dp = [0 for _ in heights]
    dp [0] = 0
    dp [1] = abs(heights[1]-heights[0])
    for i in range(2,n):
        from_one_before = dp[i-1] + abs(heights[i] - heights[i-1])
        from_two_before = dp[i-2] + abs(heights[i] - heights[i-2])
        dp[i] = min(from_one_before,from_two_before)
    #print(dp)
    return dp[n-1]

def main():
    n = int(eval(input()))
    heights = list(map(int,input().split()))
    print((flog(heights,n)))

if __name__ == '__main__':
    main()


# Optimized solution

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



if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

INF = 10**9
dp = [INF]*N

def chmin(val1, val2):
    if val1 < val2:
        return val1
    else:
        return val2
        
for i in range(len(A)):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = abs(A[1]-A[0])
    else:
        dp[i] = chmin(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2]))

print((dp[N-1]))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
 
INF = 10**9
dp = [INF]*N

for i in range(len(A)):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = abs(A[1]-A[0])
    else:
        dp[i] = min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2]))
 
print((dp[N-1]))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
 
INF = 10**9
dp = [INF]*N

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

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
 
INF = 10**9
dp = [0] + [INF]*N
 
for i in range(1,N):
    if i == 1:
        dp[1] = abs(A[1]-A[0])
    else:
        dp[i] = min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2]))
 
print((dp[N-1]))
# Original solution
N=int(eval(input()))
h=list(map(int,input().split()))
DP=[0]*N
DP[0]=0
DP[1]=abs(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]))

# Optimized solution
def main():
  N=int(eval(input()))
  h=list(map(int,input().split()))
  DP=[0]*N
  DP[1]=abs(h[1]-h[0])
  for i in range(2,N):
    # from 2step before
    pre_2=DP[i-2] + abs(h[i]-h[i-2])
    pre_1=DP[i-1] + abs(h[i]-h[i-1])
    DP[i]=min(pre_1,pre_2)
    pass
  print((DP[-1]))

if __name__ == '__main__':
  main()
# Original solution
import sys
input = sys.stdin.readline

def main():
    #1:初期化
    N = int(eval(input()))
    #h = list(map(int, input().split()))
    h = [int(x) for x in input().split()]
    inf = float("inf")
    dp = [inf]*(N)

    #2:初期値
    dp[0] = 0

    #3:dp実行部(貰うDP)
    for i in range(1,N):
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
        if(i>1): #2つ目の足場には二個前の足場がないので．
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

    # #3:dp実行部(配るDP)
    # 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]))

    #4:出力
    print((dp[N-1]))

if __name__ == '__main__':
    main()

# Optimized solution
import sys
input = sys.stdin.readline

def main():
    #1:初期化
    N = int(eval(input()))
    h = list(map(int, input().split()))
    #h = [int(x) for x in input().split()]
    inf = float("inf")
    dp = [inf]*(N)

    #2:初期値
    dp[0] = 0

    #3:dp実行部(貰うDP)
    for i in range(1,N):
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
        if(i>1): #2つ目の足場には二個前の足場がないので．
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

    # #3:dp実行部(配るDP)
    # 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]))

    #4:出力
    print((dp[N-1]))

if __name__ == '__main__':
    main()
# Original solution
from functools import lru_cache

import sys
sys.setrecursionlimit(10 ** 7)

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

@lru_cache(maxsize=None)
def rec(n):
  # print(n)
  if n == 1:
    return 0
  elif n == 2:
    return abs(h[1]-h[0])
  else:
    return min(rec(n-1)+abs(h[n-1]-h[n-2]), rec(n-2)+abs(h[n-1]-h[n-3]))

print((rec(N)))

# Optimized solution
from functools import lru_cache

import sys
sys.setrecursionlimit(10 ** 7)

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

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

def rec(n):
  if memo[n] == None:
    memo[n] = min(rec(n-1)+abs(h[n]-h[n-1]), rec(n-2)+abs(h[n]-h[n-2]))
  return memo[n]

rec(N-1)
print((memo[N-1]))
"""
@lru_cache(maxsize=None)
def rec(n):
  # print(n)
  if n == 1:
    return 0
  elif n == 2:
    return abs(h[1]-h[0])
  else:
    return min(rec(n-1)+abs(h[n-1]-h[n-2]), rec(n-2)+abs(h[n-1]-h[n-3]))
"""

# print(rec(N))
# Original solution
'''
以下解説を参考に回答
https://qiita.com/drken/items/dc53c683d6de8aeacf5a
'''

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

# DPテーブル
dp = [10 ** 9] * N

# 初期条件
dp[0] = 0
dp[1] = abs(H[1] - H[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]))

# Optimized solution
'''
以下解説を参考に回答
https://qiita.com/drken/items/dc53c683d6de8aeacf5a
'''

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

# DPテーブル
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 - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))

# 解を出力
print((dp[N - 1]))
# Original solution
N = int(eval(input()))
h = list(map(int,input().split()))

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


# Optimized solution
N = int(eval(input()))
blank = 2
h = list(map(int,input().split())) + [0] * blank

INF = 10 ** 9 + 1
dp = [INF] * (N + blank)
dp[0] = 0
for i in range(N):
  dp[i + 1] = min(dp[i] + abs(h[i + 1] - h[i]), dp[i + 1])
  dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 2])
  
print((dp[N - 1]))
# Original solution
n = int(eval(input()))
h = list(map(int,input().split()))
inf = 10000
dp = []
for i in range(100000):
    dp.append(inf)
dp[0] = 0
for i in range(1,n):
    if i>1:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    else:
        dp[i] = dp[i-1] + abs(h[i]-h[i-1])
print((dp[n-1]))
    

# Optimized solution
N = int(eval(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]))
# Original solution
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [float('INF') for _ in range(n)]
for i in range(n):
    if 0 == i:
        dp[i] = 0
    elif 1 == i:
        dp[i] = 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[-1]))


# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))
cost = [0 for _ in range(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[-1]))
# Original solution
N = int(eval(input()))
*T, = list(map(int, input().split()))

INF = float("inf")  # pythonでの無限大の作り方
DP = [INF for i in range(N)]

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

DP[0] = 0
for i in range(1, N):
     DP[i] = chmin(DP[i], DP[i-1] + abs(T[i-1] - T[i]))
     DP[i] = chmin(DP[i], DP[i-2] + abs(T[i-2] - T[i]))

print((int(DP[-1])))

# Optimized solution
"""
dp[i] := 足場iまでにかかるコストの最小値
"""
N = int(eval(input()))
*h, = list(map(int, input().split()))
dp = [0 for _ in range(N)]
dp[1] = abs(h[0] - h[1])  # initialize dp

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

print((dp[-1]))
# Original solution
"""
dp[i] := 足場iまでにかかるコストの最小値
"""
N = int(eval(input()))
*h, = list(map(int, input().split()))
dp = [0 for _ in range(N)]
dp[1] = abs(h[0] - h[1])  # initialize dp

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

print((dp[-1]))

# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))

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

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


print((cost[-1]))