require 'pp'

N = readline.to_i
H = readline.chomp.split.map(&:to_i)

dp = Array.new(N,0)
dp[0] = 0
dp[1] = (H[1]-H[0]).abs

(2..(N-1)).each do |i|
  dp[i] = [ dp[i-2]+(H[i]-H[i-2]).abs, dp[i-1]+(H[i]-H[i-1]).abs ].min
end

puts dp[N-1]
