n   = gets.to_i
ary = gets.split.map(&:to_i)
dp  = [0, (ary[1] - ary[0]).abs]

for i in 2 .. n - 1
  dp[i] = [dp[i - 2] + (ary[i] - ary[i - 2]).abs, dp[i - 1] + (ary[i] - ary[i - 1]).abs].min
end

puts dp[-1]
