let n = Int(readLine()!)
let arr = readLine()!.split(separator: " ").map({Int($0)!})

var costArr = [Int](repeating: 0, count: arr.count)
costArr[1] = abs(arr[0] - arr[1])

for i in 2 ..< arr.count {
    costArr[i] = min(costArr[i-1] + abs(arr[i] - arr[i-1]), costArr[i-2] + abs(arr[i] - arr[i-2]))
}
print(costArr.last!)