CodeEff/ECCO huggingface dataset:
# Original solution
#!/usr/bin/env python3
import sys


def solve(N: int, h: "List[int]"):
    INF = 1000000000
    dp = [INF] * (N+100)
    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]))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, h)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
INF = 1<<32

def solve(N: int, h: "List[int]"):
    dp = [INF] * (N+2)
    dp[0] = 0
    dp[1] = abs(h[1]-h[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]))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, h)

if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
arr = list(map(int,input().split()))
tmp = [float('inf') for i in range(n)]

tmp[0] = 0
tmp[1] = abs(arr[0] - arr[1])
for j in range(2,n):
	tmp[j] = min(tmp[j],tmp[j-2]+abs(arr[j-2]-arr[j]))
	tmp[j] = min(tmp[j],tmp[j-1]+abs(arr[j-1]-arr[j]))
print((tmp[-1]))





# Optimized solution
n = int(eval(input()))

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

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

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

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

print((dp[-1]))
# Original solution
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    f, *shape, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    n = read(int)
    hs = read(int, n)
    dp = arr(n)
    dp[1] = abs(hs[1] - hs[0])
    for i in range(2, n):
        dp[i] = min(
            dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2])
        )
    print(dp[-1])


if __name__ == "__main__":
    main()


# Optimized solution
n = int(eval(input()))
hs = [int(s) for s in input().split()]

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

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

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

p = [abs(li[i]-li[i+1]) for i in range(n-1)]
q = [abs(li[i]-li[i+2]) for i in range(n-2)]

dp = [0,p[0]]

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

print((dp[-1]))


# Optimized solution
n = int(eval(input()))
h = [int(i) for i in input().split()]

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

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

print((dp[-1]))
# Original solution
from functools import lru_cache
import sys

sys.setrecursionlimit(10**6)

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

@lru_cache(maxsize=None)
def recur(i):
    if i == N - 1:
        return 0
    return min(abs(h[i] - h[i + 1]) + recur(i + 1), abs(h[i] - h[min(N - 1, i + 2)]) + recur(min(N - 1, i + 2)))

print((recur(0)))

# dp = [0]*(N + 1)
# for i in range(N):


# Optimized solution
from functools import lru_cache
import sys

sys.setrecursionlimit(10**6)

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

# @lru_cache(maxsize=None)
# def recur(i):
#     if i == N - 1:
#         return 0
#     return min(abs(h[i] - h[i + 1]) + recur(i + 1), abs(h[i] - h[min(N - 1, i + 2)]) + recur(min(N - 1, i + 2)))
#
# print(recur(0))

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

print((dp[N - 1]))
# Original solution
import sys
sys.setrecursionlimit(1000100)
n = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))

ans = []
def frog(pnt, pos):
    if pos ==n-1:
        ans.append(pnt)
    elif pos ==n-2:
        frog(pnt + abs(H[pos+1]-H[pos]), pos+1)
    else:
        frog(pnt + abs(H[pos+1]-H[pos]), pos+1)
        frog(pnt + abs(H[pos+2]-H[pos]), pos+2)
        
frog(0, 0)
print((min(ans)))

# Optimized solution
import sys
n = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))

P =[0 for _ in range(n)]
P[1] = abs(H[1]-H[0])
for pos in range(2, n):
    a = abs(H[pos]-H[pos-1])
    b = abs(H[pos]-H[pos-2])
    P[pos] = min((P[pos-1] + a), (P[pos-2] + b))

print((P[n-1]))
# Original solution
import sys
n = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))

P =[0 for _ in range(n)]
P[1] = abs(H[1]-H[0])
for pos in range(2, n):
    a = abs(H[pos]-H[pos-1])
    b = abs(H[pos]-H[pos-2])
    P[pos] = min((P[pos-1] + a), (P[pos-2] + b))

print((P[n-1]))

# Optimized solution
#EDP-A
import sys
n = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))
dp = [0 for _ in range(n)]

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

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

print((dp[-1]))
# Original solution
N=int(eval(input()))
*h,=list(map(int,input().split()))
INF=10**12

dp = [0]*N

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

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

dp = [0]*N

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

INF = float('inf')

DP = [INF] * N

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

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

print((DP[N-1]))

# Optimized solution
N = int(eval(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[0] - h[1]))
    else:
        one_hop = abs(h[i-1] - h[i]) + DP[i-1]
        two_hop = abs(h[i-2] - h[i]) + DP[i-2]
        if one_hop <= two_hop:
            DP.append(one_hop)
        else:
            DP.append(two_hop)

print((DP[-1]))
# Original solution
if __name__ == "__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):
        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
def main():
    N = int(eval(input()))
    h = list(map(int, input().split()))

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


if __name__ == "__main__":
    main()
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
A+=[0]
A+=[0]
dp=[float("INF")]*(N+2)
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(N):
  dp[i+1]=min(dp[i+1],abs(A[i+1]-A[i])+dp[i])
  dp[i+2]=min(dp[i+2],abs(A[i+2]-A[i])+dp[i])
print((dp[N-1]))

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

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

total_cost = [-1 for _ in range(N)]
total_cost[0] = 0
total_cost[1] = abs(hs[1]-hs[0])

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

print((total_cost[N-1]))


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

costs = [0 for _ in range(N)]
costs[0] = 0
costs[1] = abs(hs[0] - hs[1])

for i in range(2, N):
  costs[i] = min(costs[i-2] + abs(hs[i] - hs[i-2]), \
                 costs[i-1] + abs(hs[i] - hs[i-1]))

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

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

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

print((a[N-1]))


        

# Optimized solution
# coding: utf-8
# Your code here!

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

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

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

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

INF = 10 ** 10

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

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

print((dp[N - 1]))

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

INF = 10 ** 10

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

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

print((dp[N - 1]))
# Original solution
# 検証のためのACの人のパクリですごめんなさい
N = int(eval(input()))
hs = [i for i in map(int, input().split())]

INF = 10*12
dp = [INF]*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]-hs[i-1]), dp[i-2] +abs(hs[i]-hs[i-2]))
print((dp[-1]))

# Optimized solution
def chmin(a, b):
  if a > b:
    return b
  return a

def main():
  N = int(eval(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()
# Original solution
n = int(eval(input()))
h = [int(x) for x in input().split(" ")]
INF = 10**9
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]))

# Optimized solution
n = int(eval(input()))
h = [int(x) for x in input().split()]

INF = 10**10
dp = [INF]*n

dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    dp[i] = min(dp[i], 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]))
# Original solution
from sys import setrecursionlimit
setrecursionlimit(1000000) 
N = int(eval(input()))
H = list(map(int, input().split()))


def memoize(f):
    cache = {}
    def helper(x):
        if x not in cache:
            cache[x] = f(x)
        return cache[x]
    return helper



def jump(i):
    if i == 0:
        return 0
    a = abs(H[i] - H[i - 1]) + jump(i - 1)
    if i == 1:
        return a
    b = abs(H[i] - H[i - 2]) + jump(i - 2)
    return min(a, b)

memoizedjump = memoize(jump)
print((memoizedjump(N - 1)))


# Optimized solution
from sys import setrecursionlimit
setrecursionlimit(1000000) 
N = int(eval(input()))
H = list(map(int, input().split()))


def memoize(f):
    cache = {}
    def helper(x):
        if x not in cache:
            cache[x] = f(x)
        return cache[x]
    return helper


@memoize
def jump(i):
    if i == 0:
        return 0
    a = abs(H[i] - H[i - 1]) + jump(i - 1)
    if i == 1:
        return a
    b = abs(H[i] - H[i - 2]) + jump(i - 2)
    return min(a, b)

print((jump(N - 1)))
# Original solution
n=int(eval(input()))
h=[int(i) for i in input().split()]
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(1,n-1):
  dp[i+1]+=min(dp[i]+abs(h[i+1]-h[i]),dp[i-1]+abs(h[i+1]-h[i-1]))
print((dp[n-1]))

# Optimized solution
n=int(eval(input()))
h=[int(i) for i in input().split()]
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(1,n-1):
  dp[i+1]+=min(dp[i]+abs(h[i+1]-h[i]),dp[i-1]+abs(h[i+1]-h[i-1]))
print((dp[-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(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]))

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

print((dp[-1]))


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

# Optimized solution
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):
  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
import sys
sys.setrecursionlimit(500000)

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

def dfs(n):#足場nまでにたどり着くための最小コスト
    
    if n==0:
        return 0
    if n-1==0:
        return abs(H[n]-H[n-1])
    if dp[n]!=-1:
        return dp[n]
    ans = min(abs(H[n]-H[n-1])+dfs(n-1), abs(H[n]-H[n-2])+dfs(n-2))
    dp[n] = ans
    return ans

print((dfs(N-1)))

# Optimized solution
import sys
sys.setrecursionlimit(500000)

def dfs(n):
    global N
    if n==0:
        return 0
    if n-1==0:
        return abs(H[n]-H[n-1]) + dfs(n-1)
    if dp[n]!=-1:
        return dp[n]

    ans = 0
    ans = min(abs(H[n]-H[n-1]) + dfs(n-1), abs(H[n]-H[n-2]) + dfs(n-2))
    dp[n] = ans
    return ans

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

dp = [-1]*N

print((dfs(N-1)))
# Original solution
import sys
input = sys.stdin.readline

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

def main():
    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[-1]))
    
if __name__ == "__main__":
    main()

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

def main():
    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[-1]))
    
if __name__ == "__main__":
    main()
# Original solution
import sys
sys.setrecursionlimit(10**7)

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

cost = [0, abs(h[1]-h[0])]
def dp(i):
  if i >= len(cost):
    cost.append(min(dp(i-1)+abs(h[i]-h[i-1]), dp(i-2)+abs(h[i]-h[i-2])))
  return cost[i]

print((dp(N-1)))

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

def dp(n):
  a, b = 0, abs(h[1]-h[0])
  if n == 0:
    return a
  for i in range(2, n+1):
    a, b = b, min(a+abs(h[i]-h[i-2]), b+abs(h[i]-h[i-1]))
  return b
 
print((dp(N-1)))
# Original solution
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-2]+abs(h[i]-h[i-2]),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= [10 ** 9 + 7] * (n + 10)

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=[int(i) for i in input().split()]
dp=[0]*(N+5)
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[N-1]))

# Optimized solution
N = int(eval(input()))
H=list(map(int,input().split()))
#print(H)
INF=1000000000
dp=[INF]*(N+1)
#print(dp)
dp[0]=0
#print(dp[0])
#print(H[1],H[0])
dp[1]=dp[0]+abs(H[1]-H[0])
for i in range(2,N):
  dp[i]=min(dp[i-2]+abs(H[i-2]-H[i]),dp[i-1]+abs(H[i-1]-H[i]))
print((dp[N-1]))
# Original solution
n=int(eval(input()))
h=[int(i) for i in input().split()]
def frog(x):
    if len(x)<=3:
        return(abs(x[0]-x[-1]))

    else:
        step1=abs(x[0]-x[1])
        step2=abs(x[0]-x[2])
        return min(step1+frog(x[1:]),step2+frog(x[2:]))

print((frog(h)))


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

INF = int(1e20)
dp = [INF] * (N)
dp[0] = 0


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

print((dp[N-1]))

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

# DP
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]))
# Original solution
N = int(eval(input()))
h = list(map(int, input().split()))

# DP
inf = float("inf")
dp = [inf for _ in range(N)]
dp[0] = 0
for i in range(1, N):
    if i == 1:
        dp[i] = abs(h[i] - h[i-1])
    else:
        dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]))
print((dp[-1]))

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

INF = float('inf')
dp = [INF] * n
dp[0] = 0
# dp[i] = (足場iにたどり着いた時点でのコストの最小値)

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]))


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

INF = float('inf')
dp = [INF] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])
# dp[i] = (足場iにたどり着いた時点でのコストの最小値)

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
#  入力
#  足場の高さ
eval(input())
h = list(map(int, input().split()))


#  方針
#  i番目の足場にいるという状態に対して
#  その足場に最も少ないコストを記録する．

#  初期化は大きは数で
dp = [1e20 for i in range(len(h))]
#  スタートはコスト0
dp[0] = 0

#  i番目の足場でのコストを利用して
#  i+1, i+2番目のコストを計算する
for i in range(len(h) - 1):
    dp[i + 1] = (
        dp[i + 1]
        if dp[i + 1] < dp[i] + abs(h[i + 1] - h[i])
        else dp[i] + abs(h[i + 1] - h[i])
    )
    if i + 2 < len(h):
        dp[i + 2] = (
            dp[i + 2]
            if dp[i + 2] < dp[i] + abs(h[i + 2] - h[i])
            else dp[i] + abs(h[i + 2] - h[i])
        )

print((dp[len(h) - 1]))


# Optimized solution
#  入力
#  足場の高さ
eval(input())
h = list(map(int, input().split()))


#  方針
#  i番目の足場にいるという状態に対して
#  その足場に最も少ないコストを記録する．

#  スタートはコスト0
dp = [0]

#  i番目の足場でのコストを
#  i-1, i-2番目のコストを利用して計算する
#  1番目は手動で更新した方がコードが簡単になる．
dp.append(dp[0] + abs(h[1] - h[0]))

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

print((dp[len(h) - 1]))
# Original solution
n = int(eval(input()))
height = list(map(int, input().split()))

dis = [0] * n
dis[1] = abs(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]))

# Optimized solution
n = int(eval(input()))
k = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(k[1] - k[0])

for i in range(2, n):
    dp[i] = min(abs(k[i]-k[i-1])+dp[i-1], abs(k[i]-k[i-2]) +dp[i-2])
print((dp[-1]))
# Original solution
N = int(eval(input()))
hs = list(map(int, input().split()))

"""
dp[i] i番目に到達するときの最小値
遷移
送るDP
i-1段目まで下記を実施
dp[i+1] = min(dp[i+1], dp[i]+コスト)
if (一段飛ばしできる余地があれば): 
    dp[i+2] = min(dp[i+2],dp[i]+コスト)

"""
INF = 10**9+7
dp = [INF]*101000
dp[0] = 0
for i in range(1,N):
    if i-2 >= 0:
        cost2 = abs(hs[i]-hs[i-2])
        dp[i] = min(dp[i],dp[i-2]+cost2)
    cost1 = abs(hs[i]-hs[i-1])
    dp[i] = min(dp[i],dp[i-1]+cost1)

print((dp[N-1]))

# Optimized solution

"""
dp[i] : 足場iに到達するにあたって、たどり着く最小回数
"""
INF = 10**10
dp = [INF]*110000
N = int(eval(input()))
hs  = list(map(int, input().split())) + [INF,INF]
dp[0] = 0
for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i]+abs(hs[i+1]-hs[i]))
    dp[i+2] = min(dp[i+2], dp[i]+abs(hs[i+2]-hs[i]))
print((dp[N-1]))
# Original solution
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  5 15:34:44 2019

@author: avina
"""

n = int(eval(input()))
L = list(map(int, input().strip().split()))
dp = [0 for i in range(n)]
dp[1] = abs(L[1] - L[0]) 
for j in range(2,n):
    for i in range(j,j+2):
        if i < n:
            dp[i] = min(dp[i-2] + abs(L[i]-L[i-2]),dp[i-1] + abs(L[i] - L[i-1]))

print((dp[-1]))

# Optimized solution
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  8 08:28:30 2019

@author: avina
"""

n = int(eval(input()))
l = list(map(int, input().split()))
dp= [0]*n

for i in range(1,n):
    b = 1e6
    a = dp[i-1] + abs(l[i] - l[i-1])
    if i -2 >-1:
        b = dp[i-2] + abs(l[i] - l[i-2])
    dp[i] = min(a,b)    
print((dp[-1]))
# Original solution
n=int(eval(input()))
h=list(map(int,input().split()))

# nの足場までいく最小コストを a_n とする。
# a_1のコストは0,  a_2のコストは(h_1からの１通りなので)\h_1-h_2\
dp=[0]*n
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(h[i]-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]*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]))