'use strict'
const lines = require('fs').readFileSync(0, 'utf8').split('\n')
const N = parseInt(lines[0], 10)
const map = lines[1].split(' ').map((v) => parseInt(v, 10))
let ans = Infinity
function step(pos, cost, prev) {
  if (pos === N) return cost
  for (let j=1;j<=2;j++) {
    if (pos + j > N || (prev === 1 && j === 1)) continue
    ans = Math.min(step(pos+j, cost+Math.abs(map[pos-1] - map[pos+j-1]), j), ans)
  }
  return ans
}
step(1, 0, 0)
console.log(ans)