'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])
function dfs(pos) {
  if (pos > N - 1) return Infinity
  else if (dp[pos] !== undefined) return dp[pos]
  const step1 = dfs(pos-1) + Math.abs(map[pos] - map[pos-1])
  const step2 = dfs(pos-2) + Math.abs(map[pos] - map[pos-2])
  return dp[pos] = Math.min(step1, step2)
}
console.log(dfs(N-1))