N = int(eval(input()))

h = [int(h) for h in input().split()]



def jump(i, j):

    return abs(h[j] - h[i])



a, b = 0, jump(0, 1)

for i in range(2, N):

    a, b = b, min(b + jump(i - 1, i), a + jump(i - 2, i))

print(b)

def solve(n, stone_heights):

  if n == 0 or n == 1: return 0

  if n == 2:

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

  cost_arr = [0, abs(stone_heights[1] - stone_heights[0])]

  i = 2

  while i < n:

    cost_to_i_from_1_stone_before = abs(stone_heights[i] - stone_heights[i - 1])

    cost_to_i_from_2_stones_before = abs(stone_heights[i] - stone_heights[i - 2])

    if cost_to_i_from_2_stones_before + cost_arr[i - 2] <= cost_to_i_from_1_stone_before + cost_arr[i - 1]:

      cost_arr.append(cost_to_i_from_2_stones_before + cost_arr[i - 2])

    else:

      cost_arr.append(cost_to_i_from_1_stone_before + cost_arr[i - 1])

    i += 1

  return cost_arr[-1]



n = int(eval(input()))

stone_heights = list(map(int,input().rstrip().split(' ')))

print((solve(n, stone_heights)))

N = int(eval(input()))
h = [int(h) for h in input().split()]


def jump(i, j):
    return abs(h[j] - h[i])


a, b = 0, jump(0, 1)
for i in range(2, N):
    a, b = b, min(b + jump(i - 1, i), a + jump(i - 2, i))
print(b)

def solve(n, stone_heights):
    if n == 0 or n == 1:
        return 0
    if n == 2:
        return abs(stone_heights[1] - stone_heights[0])
    cost_arr = [0, abs(stone_heights[1] - stone_heights[0])]
    i = 2
    while i < n:
        cost_to_i_from_1_stone_before = abs(stone_heights[i] - stone_heights[i - 1])
        cost_to_i_from_2_stones_before = abs(stone_heights[i] - stone_heights[i - 2])
        if (
            cost_to_i_from_2_stones_before + cost_arr[i - 2]
            <= cost_to_i_from_1_stone_before + cost_arr[i - 1]
        ):
            cost_arr.append(cost_to_i_from_2_stones_before + cost_arr[i - 2])
        else:
            cost_arr.append(cost_to_i_from_1_stone_before + cost_arr[i - 1])
        i += 1
    return cost_arr[-1]


n = int(eval(input()))
stone_heights = list(map(int, input().rstrip().split(" ")))
print((solve(n, stone_heights)))

-N = int(eval(input())) -h = [int(h) for h in input().split()] +def solve(n, stone_heights): +    if n == 0 or n == 1: +        return 0 +    if n == 2: +        return abs(stone_heights[1] - stone_heights[0]) +    cost_arr = [0, abs(stone_heights[1] - stone_heights[0])] +    i = 2 +    while i < n: +        cost_to_i_from_1_stone_before = abs(stone_heights[i] - stone_heights[i - 1]) +        cost_to_i_from_2_stones_before = abs(stone_heights[i] - stone_heights[i - 2]) +        if ( +            cost_to_i_from_2_stones_before + cost_arr[i - 2] +            <= cost_to_i_from_1_stone_before + cost_arr[i - 1] +        ): +            cost_arr.append(cost_to_i_from_2_stones_before + cost_arr[i - 2]) +        else: +            cost_arr.append(cost_to_i_from_1_stone_before + cost_arr[i - 1]) +        i += 1 +    return cost_arr[-1] -def jump(i, j): -    return abs(h[j] - h[i]) - - -a, b = 0, jump(0, 1) -for i in range(2, N): -    a, b = b, min(b + jump(i - 1, i), a + jump(i - 2, i)) -print(b) +n = int(eval(input())) +stone_heights = list(map(int, input().rstrip().split(" "))) +print((solve(n, stone_heights)))