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

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

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

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

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

puts dp[n-1]