INF = 10010
N_MAX = 100010

n = gets.to_i
hs = gets.chomp.split(' ').map(&:to_i)

h = {}
dp = {}
N_MAX.times do |i|
  h[i] = hs[i]
  dp[i] = INF
end

dp[0] = 0
(1...n).each do |i|
  dp[i] = dp[i-1] + (h[i] - h[i-1]).abs
  next if i == 1

  diff = dp[i-2] + (h[i] - h[i-2]).abs
  dp[i] = diff if dp[i] > diff
end

print(dp[n-1])