'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 = Array(N)
function dfs(pos) { // posからNまでの最小コスト
  if (pos >= N) return Infinity
  else if (pos === N-1) return 0
  else if (!!dp[pos]) return dp[pos]
  const step1 = Math.abs(map[pos] - map[pos+1]) + dfs(pos+1)
  if (pos === N-2) return dp[pos] = step1
  const step2 = Math.abs(map[pos] - map[pos+2]) + dfs(pos+2)
  return dp[pos] = Math.min(step1, step2)
}
console.log(dfs(0))