import itertools

import math

import sys

from collections import Counter

from fractions import gcd

from functools import reduce

import sys

sys.setrecursionlimit(4100000)



INF = 1 << 60



# ここから書き始める

n = int(eval(input()))

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

dp = [INF] * n

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

# edpc a



import itertools

from math import factorial

import sys

import heapq

from collections import Counter

from collections import deque

from fractions import gcd

from functools import reduce



sys.setrecursionlimit(4100000)

INF = 1 << 60

MOD = 10 ** 9 + 7



# ここから書き始める

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

    cost_from_2 = dp[i - 2] + abs(h[i] - h[i - 2])

    cost_from_1 = dp[i - 1] + abs(h[i] - h[i - 1])

    dp[i] = min(cost_from_1, cost_from_2)

# print(dp)

print((dp[n - 1]))

import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce
import sys

sys.setrecursionlimit(4100000)
INF = 1 << 60
# ここから書き始める
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [INF] * n
dp[0] = 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[-1]))

# edpc a
import itertools
from math import factorial
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10**9 + 7
# ここから書き始める
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):
    cost_from_2 = dp[i - 2] + abs(h[i] - h[i - 2])
    cost_from_1 = dp[i - 1] + abs(h[i] - h[i - 1])
    dp[i] = min(cost_from_1, cost_from_2)
# print(dp)
print((dp[n - 1]))

+# edpc a -import math +from math import factorial +import heapq +from collections import deque -import sys +MOD = 10**9 + 7 -dp = [INF] * n +dp = [0] * n -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[-1])) +dp[1] = abs(h[1] - h[0]) +for i in range(2, n): +    cost_from_2 = dp[i - 2] + abs(h[i] - h[i - 2]) +    cost_from_1 = dp[i - 1] + abs(h[i] - h[i - 1]) +    dp[i] = min(cost_from_1, cost_from_2) +# print(dp) +print((dp[n - 1]))