#!/usr/bin/ruby
#encoding: utf-8

# 配るDPで書く

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

dp = Array.new(n+1,1e9.to_i)

dp[0] = 0

(0..n-2).each do |i|
  dp[i+1] = [dp[i+1] , dp[i] + (h[i+1] - h[i]).abs].min
  if i != n-2
    dp[i+2] = [dp[i+2] , dp[i] + (h[i+2] - h[i]).abs].min
  end
end

puts dp[n-1]