n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
path = []
path[0..1] = [0,(a[1]-a[0]).abs]
for i in 2..n-1
  path[i] = [path[i-2]+(a[i]-a[i-2]).abs,path[i-1]+(a[i]-a[i-1]).abs].min
end
puts path[-1]