
n = gets.to_i
$_h = gets.split.map {|x| x.to_i}

def h(i)
  return $_h[i-1]
end

def abs(x)
  return x < 0 ? -x : x
end
def min(x,y)
  return x < y ? x : y
end

$min_cost = Array.new(n+1, -1)

$min_cost[1] = 0
$min_cost[2] = abs(h(1) - h(2))

def calc(i)
  if ($min_cost[i] < 0)
    $min_cost[i] = min(calc(i-1) + abs(h(i) - h(i-1)), calc(i-2) + abs(h(i) - h(i-2)))
  end
  return $min_cost[i]
end

p calc(n)
