import sys

sys.setrecursionlimit(100000) 



n = int(eval(input()))

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

dp_ = [-1]*n



def dp(i):

    if dp_[i]!=-1:

        return dp_[i]

    if i == 0:

        dp_[i] = 0

    elif i == 1:

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

    else:

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

    return dp_[i]



print((dp(n-1)))
#A

n = int(eval(input()))

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



cost = [0]*n

for i in range(n):

    if i == 0:

        continue

    if i == 1:

        cost[i] = abs(h[i]-h[i-1])

        continue

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

print((cost[n-1]))
import sys

sys.setrecursionlimit(100000)
n = int(eval(input()))
h = list(map(int, input().split()))
dp_ = [-1] * n


def dp(i):
    if dp_[i] != -1:
        return dp_[i]
    if i == 0:
        dp_[i] = 0
    elif i == 1:
        dp_[i] = abs(h[1] - h[0])
    else:
        dp_[i] = min(dp(i - 2) + abs(h[i] - h[i - 2]), dp(i - 1) + abs(h[i] - h[i - 1]))
    return dp_[i]


print((dp(n - 1)))

# A
n = int(eval(input()))
h = list(map(int, input().split()))
cost = [0] * n
for i in range(n):
    if i == 0:
        continue
    if i == 1:
        cost[i] = abs(h[i] - h[i - 1])
        continue
    cost[i] = min(
        cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2])
    )
print((cost[n - 1]))

-import sys - -sys.setrecursionlimit(100000) +# A -dp_ = [-1] * n - - -def dp(i): -    if dp_[i] != -1: -        return dp_[i] +cost = [0] * n +for i in range(n): -        dp_[i] = 0 -    elif i == 1: -        dp_[i] = abs(h[1] - h[0]) -    else: -        dp_[i] = min(dp(i - 2) + abs(h[i] - h[i - 2]), dp(i - 1) + abs(h[i] - h[i - 1])) -    return dp_[i] - - -print((dp(n - 1))) +        continue +    if i == 1: +        cost[i] = abs(h[i] - h[i - 1]) +        continue +    cost[i] = min( +        cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2]) +    ) +print((cost[n - 1]))