n = STDIN.gets.to_i
h = STDIN.gets.split.map(&:to_i)

tiles = Array.new(n)
tiles[0] = 0

for i in 1...n do
  tiles[i] = tiles[i - 1] + (h[i] - h[i - 1]).abs
  if i - 2 >= 0 && tiles[i] > tiles[i - 2] + (h[i] - h[i - 2]).abs
    tiles[i] = tiles[i - 2] + (h[i] - h[i - 2]).abs
  end
end

puts tiles[-1]
