let N = Int(readLine()!)!
let h = readLine()!.split(separator: " ").map { Int($0)! }
var dp: [Int] = .init(repeating: Int.max, count: N)
dp[0] = 0
for i in 0..<N-1 {
  dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i+1] - h[i]))
  if i + 2 < N {
  	dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i+2] - h[i]))
  }
}
print(dp[N-1])