def memoize(f):

    cache={}

    def helper(*args):

        if args not in cache:

            cache[args] = f(*args)

        return cache[args]

    return helper



N = int(eval(input()))

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



import sys

sys.setrecursionlimit(1000000)



@memoize

def f(n):

    if n==1:

        return 0

    elif n==2:

        return abs(h[1]-h[0])

    elif n==3:

        return abs(h[2]-h[0])

    else:

        return min(f(n-1)+abs(h[n-1]-h[n-2]),f(n-2)+abs(h[n-1]-h[n-3]))



print((f(N)))

N = int(eval(input()))

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



d = [0]*N



for i in range(1,N):

    if i==1:

        d[i]=abs(h[1]-h[0])

    elif i==2:

        d[i]=abs(h[2]-h[0])

    else:

        d[i]=min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]))



print((d[N-1]))

def memoize(f):
    cache = {}

    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]

    return helper


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

sys.setrecursionlimit(1000000)


@memoize
def f(n):
    if n == 1:
        return 0
    elif n == 2:
        return abs(h[1] - h[0])
    elif n == 3:
        return abs(h[2] - h[0])
    else:
        return min(
            f(n - 1) + abs(h[n - 1] - h[n - 2]), f(n - 2) + abs(h[n - 1] - h[n - 3])
        )


print((f(N)))

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

-def memoize(f): -    cache = {} - -    def helper(*args): -        if args not in cache: -            cache[args] = f(*args) -        return cache[args] - -    return helper - - -import sys - -sys.setrecursionlimit(1000000) - - -@memoize -def f(n): -    if n == 1: -        return 0 -    elif n == 2: -        return abs(h[1] - h[0]) -    elif n == 3: -        return abs(h[2] - h[0]) +d = [0] * N +for i in range(1, N): +    if i == 1: +        d[i] = abs(h[1] - h[0]) +    elif i == 2: +        d[i] = abs(h[2] - h[0]) -        return min( -            f(n - 1) + abs(h[n - 1] - h[n - 2]), f(n - 2) + abs(h[n - 1] - h[n - 3]) -        ) - - -print((f(N))) +        d[i] = min(d[i - 1] + abs(h[i] - h[i - 1]), d[i - 2] + abs(h[i] - h[i - 2])) +print((d[N - 1]))