const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
const N = parseInt(input[0]) - 1
const floor = input[1].split(' ').map(Number)

const solver = (n, cost) => {
  if (n == N) {
    return 0
  }

  const jump1 = Math.abs(floor[n] - floor[n+1]) + solver(n+1, cost)

  if ((n + 1) == N) {
    return jump1
  }

  const jump2 = Math.abs(floor[n] - floor[n+2]) + solver(n+2, cost)

  return Math.min(jump1, jump2)
}

console.log(solver(0, 0))