CodeEff/ECCO huggingface dataset:
# Original solution
# coding: utf-8
# Your code here!
import math
n=int(eval(input()))
h=list(map(int,input().split()))
dp=[math.inf for _ in range(n)]
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[n-1]))

# Optimized solution

n=int(eval(input()))
h=list(map(int,input().split()))
dp=[0 for i in range(n)]
for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print((dp[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.append(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 input_li():
    return list(map(int, input().split()))

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

N = input_int()
h_li = input_li()
dp = [0] * N
dp[0] = 0
dp[1] = abs(h_li[1] - h_li[0])
for i in range(2, N):
    dp[i] = min(
        dp[i - 1] + abs(h_li[i] - h_li[i - 1]),
        dp[i - 2] + abs(h_li[i] - h_li[i - 2])
    )
print((dp[-1]))
# Original solution
import sys

sys.setrecursionlimit(1000000)

def input_from_console():
    n = int(input().strip())
    h_list = list(map(int, input().split()))
    return n, h_list


def solve(n, h_list):
    dp = [-1] * (n+2)
    dp[0] = 0
    dp[1] = abs(h_list[1]- h_list[0])
    def dp_solve(i):
        if dp[i] != -1:
            return dp[i]
        dp[i] = min(
            dp_solve(i-1) + abs(h_list[i] - h_list[i-1]),
            dp_solve(i-2) + abs(h_list[i] - h_list[i-2]),
        )
        return dp[i]
    return dp_solve(n-1)


def main():
    n, h_list = input_from_console()
    print((solve(n, h_list)))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


# Optimized solution
def input_from_console():
    n = int(input().strip())
    h_list = list(map(int, input().split()))
    return n, h_list


def solve(n, h_list):
    import sys
    sys.setrecursionlimit(200000)

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

    def recursive_dp_sover(i):
        if dp[i] != -1:
            return dp[i]
        dp[i] = min(
            recursive_dp_sover(i - 1) + abs(h_list[i] - h_list[i - 1]),
            recursive_dp_sover(i - 2) + abs(h_list[i] - h_list[i - 2])
        )
        return dp[i]

    return recursive_dp_sover(n - 1)


def main():
    n, h_list = input_from_console()
    print((solve(n, h_list)))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()
# Original solution
n=int(eval(input()))
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0],dp[1]=0,abs(h[1]-h[0])

for i in range(2,n):
    pre1=abs(h[i]-h[i-1])+dp[i-1]
    pre2=abs(h[i]-h[i-2])+dp[i-2]
    dp[i]=min(pre1,pre2)
print((dp[-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[-1]))
# Original solution
import sys
sys.setrecursionlimit(100000)
input=lambda : sys.stdin.readline().rstrip('\n')

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

dp=[10**18 for i in range(n)]
def cost(n):
    if n==0:
        return 0
    if n<0:
        return 10**18
    if dp[n]!=10**18:
        return dp[n]
    return min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]))

print((cost(n-1)))


# Optimized solution
import sys
sys.setrecursionlimit(100000)
input=lambda : sys.stdin.readline().rstrip('\n')

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

dp=[10**18 for i in range(n)]
def cost(n):
    if n==0:
        return 0
    if n<0:
        return 10**18
    if dp[n]!=10**18:
        return dp[n]
    dp[n] = min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]))
    return dp[n]

print((cost(n-1)))
# Original solution
import sys
sys.setrecursionlimit(100000)
input=lambda : sys.stdin.readline().rstrip('\n')

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

dp=[10**18 for i in range(n)]
def cost(n):
    if n==0:
        return 0
    if n<0:
        return 10**18
    if dp[n]!=10**18:
        return dp[n]
    dp[n] = min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]))
    return dp[n]

print((cost(n-1)))


# Optimized solution
import sys
sys.setrecursionlimit(2000000000)
input=lambda : sys.stdin.readline().rstrip('\n')

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

dp=[10**18 for i in range(n)]
def cost(n):
    if n==0:
        return 0
    if n<0:
        return 10**18
    if dp[n]!=10**18:
        return dp[n]
    dp[n] = min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]))
    return dp[n]

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

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

N = int(eval(input()))
h = list(map(int, input().split()))
h += [math.inf, math.inf]

dp = list([math.inf for i in range(N + 2)])  # dpテーブル
dp[0] = 0
for i in range(N):
    if dp[i + 1] > (dp[i] + abs(h[i] - h[i + 1])):
        dp[i + 1] = (dp[i] + abs(h[i] - h[i + 1]))
    else:
        dp[i + 1] = dp[i + 1]
    if dp[i + 2] > dp[i] + abs(h[i] - h[i + 2]):
        dp[i + 2] = dp[i] + abs(h[i] - h[i + 2])
    else:
        dp[i + 2] = dp[i + 2]

print((dp[N - 1]))


# Optimized solution

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


def chmax(a, b): return a if a > b else b


"""もらうDP"""
import math

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

dp = list([math.inf for i in range(N)])  # dpテーブル
dp[0] = 0
for i in range(N):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

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
dp[1]=abs(h[1]-h[0])
for i in range(2,len(h)):
  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
import sys
readline = sys.stdin.readline

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

INF = 10 ** 10
dp = [INF] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2,len(dp)):
  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]))
# Original solution
# dp[i]: i+1にくるまでにかかったコストの最小値
N = int(eval(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]-h[i+1]))
    if i < N-2:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))
print((dp[-1]))

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

dp = [float("inf")]*(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]))
# Original solution
n,*h=list(map(int,open(0).read().split()))
a=[0]+[abs(h[1]-h[0])]+[10**8]*(n-2)
for i in range(2,n):
    a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print((a[-1]))

# Optimized solution
n,*h=list(map(int,open(0).read().split()));a=[0]+[abs(h[1]-h[0])]+[0]*(n-2)
for i in range(2,n):
    a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print((a[-1]))
# Original solution
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(eval(input()))
def LS(): return input().split()
def S(): return eval(input())

def main():
  n=I()
  l=LI()

  dp=[0]*100010

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

  return dp[n]

print((main()))


# Optimized solution
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(eval(input()))
def LS(): return input().split()
def S(): return eval(input())

def main():
  n=I()
  l=LI()

  dp=[inf]*100010
  dp[0]=0
  dp[1]=0
  dp[2]=abs(l[1]-l[0])

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

  return dp[n]

print((main()))
# Original solution
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(eval(input()))
def LS(): return input().split()
def S(): return eval(input())

def main():
  n=I()
  l=LI()

  dp=[0]*100010

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

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

  return dp[n-1]

print((main()))


# Optimized solution
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(eval(input()))
def LS(): return input().split()
def S(): return eval(input())

def main():
  n=I()
  l=LI()

  dp=[inf]*100010
  dp[0]=0
  dp[1]=abs(l[0]-l[1])

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

  return dp[n-1]

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

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

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

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)

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

def main():
    if N==2:
        print((abs(H[1] - H[0])))
        return

    costs = [0 for _ in range(N)]
    costs[1] = abs(H[1]-H[0])
    costs[2] = min(costs[0]+abs(H[1]-H[0]), abs(H[2]-H[0]))

    for i in range(2,N):
        cost_1 = abs(H[i] - H[i-1]) # 1段上る
        cost_2 = abs(H[i] - H[i-2]) # 2段上る
        costs[i] = min(costs[i-1] + cost_1, costs[i-2] + cost_2) 
    print((costs[-1]))
    

if __name__ == "__main__":
    main()

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

def main():
    if N==2:
        print((abs(H[1] - H[0])))
        return

    costs = [0 for _ in range(N)]
    costs[1] = abs(H[1]-H[0])
    costs[2] = min(costs[0] + abs(H[1]-H[0]), abs(H[2]-H[0])) # 0>1>2と0>2のmin

    for i in range(2,N):
        step_1 = abs(H[i] - H[i-1]) # 1段上る
        step_2 = abs(H[i] - H[i-2]) # 2段上る
        # 漸化式 fn = min(fn-1, fn-2)
        costs[i] = min(costs[i-1] + step_1, costs[i-2] + step_2) 
    print((costs[-1]))
    

if __name__ == "__main__":
    main()
# Original solution
"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
import math
import sys
# input = sys.stdin.readline

############ ---- Input Functions ---- ############
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())))

length_path = int(eval(input()))
path = inlt()
dp = [float('inf')] * length_path
dp[0] = 0
for i in range(length_path):
    for j in range(i+1, i + 2 + 1):
        if j < length_path:
            dp[j] = min(dp[j], dp[i] + abs(path[j] - path[i]))
print((dp[length_path - 1]))

# Optimized solution
"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
import math
import sys
# input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp(): #Reads integer input
    return(int(eval(input())))
def inlt(): #Reads list of int
    return(list(map(int,input().split())))
def insr():
    s = eval(input())
    return(list(s[:len(s) - 1]))
def invr(): #Reads numbers into separate var
    return(list(map(int,input().split())))

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

dp = [100000] * n

dp[0] = 0

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

dp[0] = 0

for i in range(0, n):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = abs(h[i-1] - h[i])
    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 = [int(i) for i in input().split()]

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

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

dp = [0] * (N)

for i in range(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]))
    elif i == 1:
        dp[i] = 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)

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[-1]))
# Original solution
N = int(eval(input()))
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
#全ノードを取り敢えずinfにしておく
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-3:
        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 = [float('inf')]*N
#dp[i]は足場ｉにいくためのコストの最小値
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(N-2):
    for j in range(1,3):
        dp[i+j] = min(dp[i]+abs(H[i]-H[i+j]),
                      dp[i+1]+abs(H[i+1]-H[i+j]))
print((dp[-1]))
# Original solution
n = int(eval(input()))
h = list(map(int,input().split()))
if n == 2:
    print((abs(h[0]-h[1])))
else:
    lst = set([format(x,'b').zfill(n-2) + '1' for x in set(range((n-2) ** 2))])
    del_lst = set()
    for i in lst:
        if '00' in i:
            del_lst.add(i)
    lst = list(lst - del_lst) 
    ans =[[h[0],0] for i in range(len(lst))]

    for i in range(len(lst)):
        k = 1
        for j in lst[i]:
            if j == '1':
                ans[i][1] += abs(h[k] - ans[i][0])
                ans[i][0] = h[k]
            k += 1
    print((min(ans)[1]))

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

cost = [float('inf') for _ in range(n)]
cost[0] = 0

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

print((cost[n - 1]))


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

cost = [9999999999] * n
cost[0] = 0

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

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

print((dp[size-1]))


# Optimized solution
n = int(eval(input()))
arr = list(map(int, input().split()))
dp = [0 for i in range(n)]
sum = 0
dp[1] = abs(arr[1]-arr[0])
for i in range(2, len(arr)):
    dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
print((dp[-1]))
# Original solution
if __name__ == "__main__":
    N = int(eval(input()))
    h = [int(n) for n in input().split()]
    dp = [0] * int(1e5) # dp[i]はiにたどり着くコストの最小値
    # dp[0] = 0
    # dp[n] = min(dp[n-1] + abs(h[n] - h[n-1]), dp[n-2] + |h[n] - h[n-2]|)
    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]))


# Optimized solution
def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    dp = [-1]*N
    dp[0] = 0
    dp[1] = abs(A[1] - A[0])
    for i in range(2,N):
        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]))
main()
# Original solution
"""
https://atcoder.jp/contests/dp/tasks/dp_a
"""
from copy import deepcopy
N = int(eval(input()))
arr = [int(i) for i in input().split(" ")]

def getMinSteps():
    dp_2 = [0, ]
    dp_1 = [abs(arr[1] - arr[0]), ]
    
    total_cost = 0
    i = 2
    
    while i < N:
        diff1 = abs(arr[i] - arr[i-1])
        diff2 = abs(arr[i] - arr[i-2])
        temp = deepcopy(dp_2)
        dp_2 = deepcopy(dp_1)

        for j in range(len(dp_1)):
            dp_1[j] += diff1

        for j in range(len(temp)):
            dp_1.append(temp[j] + diff2)

        i += 1
    return min(dp_1)

        
print((getMinSteps()))

# Optimized solution
"""
https://atcoder.jp/contests/dp/tasks/dp_a
"""
from copy import deepcopy
N = int(eval(input()))
arr = [int(i) for i in input().split(" ")]

def getMinSteps():
    dp_2 = [0, ]
    dp_1 = [abs(arr[1] - arr[0]), ]
    
    total_cost = 0
    i = 2
    
    while i < N:
        diff1 = abs(arr[i] - arr[i-1])
        diff2 = abs(arr[i] - arr[i-2])
        temp = deepcopy(dp_2)
        dp_2 = deepcopy(dp_1)

        for j in range(len(dp_1)):
            dp_1[j] += diff1

        for j in range(len(temp)):
            dp_1.append(temp[j] + diff2)
            
        dp_1 = sorted(dp_1)[0:2]
        
        i += 1
    return min(dp_1)

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

# Optimized solution
n = int(eval(input()))
A = [int(i) for i in input().split()]
dp = [0] * n

dp[1] = abs(A[0] - A[1])
for i in range(2, n):
    route1 = abs(A[i] - A[i-2]) + dp[i-2]
    route2 = abs(A[i] - A[i-1]) + dp[i-1]
    dp[i] = min(route1, route2)
    
print((dp[-1]))
# Original solution
import sys

sys.setrecursionlimit(100000)

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

def sumOfCost(i):
  if i == 0:
    return 0
  elif i == 1:
    return sumOfCost(0)+abs(H[i]-H[0])
  else:
    c1 = sumOfCost(i-1)+abs(H[i]-H[i-1])
    c2 = sumOfCost(i-2)+abs(H[i]-H[i-2])
    return min(c1,c2)
print(sumOfCost(N-1))




# Optimized solution
import sys

sys.setrecursionlimit(100000)

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

def sumOfCost(i):
  if cost[i] >= 0:
    return cost[i]
  if i == 0:
    soc=0
  elif i == 1:
    soc= sumOfCost(0)+abs(H[i]-H[0])
  else:
    c1 = sumOfCost(i-1)+abs(H[i]-H[i-1])
    c2 = sumOfCost(i-2)+abs(H[i]-H[i-2])
    soc=min(c1,c2)
  cost[i] = soc
  return soc

print(sumOfCost(N-1))
# Original solution
import sys
INF=100000000
def frog(i,h,dp):
    global INF
    if dp[i]!=INF:
        return dp[i]
    else:
        if i==1:
            dp[i]=0
            return dp[i]
        elif i==2:
            dp[i]=abs(h[1]-h[0])
            return dp[i]
        else:
            dp[i]=min(frog(i-2,h,dp)+abs(h[i-1]-h[i-3]),frog(i-1,h,dp)+abs(h[i-1]-h[i-2]))
            return dp[i]
sys.setrecursionlimit(INF)
N=int(eval(input()))
h=list(map(int,input().split()))
dp=[INF for i in range(N+1)]
print((frog(N,h,dp)))


# Optimized solution
INF=10**15
N=int(eval(input()))
h=list(map(int,input().split()))
dp=[INF for i in range(N)]
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]))
# Original solution
n = int(eval(input()))

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

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

for i in range(2, n):
	dp.append(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 = [int(x) for x in input().split()]
dp = [0 for _ in range(n+1)]
dp[2] = abs(hs[1] - hs[0])
for i in range(3, n + 1):
    one = dp[i-2] + abs(hs[i-1] - hs[i-3])
    two = dp[i-1] + abs(hs[i-1] - hs[i-2])
    dp[i] = min(one, two)
print((dp[n]))