'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))
const dp = []
dp[0] = 0
dp[1] = Math.abs(map[1] - map[0])
for (let i=2;i<N;i++) {
  const step1 = dp[i-1] + Math.abs(map[i] - map[i-1])
  const step2 = dp[i-2] + Math.abs(map[i] - map[i-2])
  dp[i] = Math.min(step1, step2)
}
console.log(dp[N-1])