N = gets.chomp.to_i
H = gets.split.map &:to_i

dp = []

dp[0] = 0
dp[1] = (H[1] - H[0]).abs

def min(a,b)
  a < b ? a : b
end

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

p dp.last
