let n = Int(readLine()!)!
let h = readLine()!.split{$0 == " "}.map{Int($0)!}
var d = [Int](repeating: 0, count: n), c = d

func f(_ x: Int)->Int {
    if x <= 1 {
        return abs(h[x] - h[0])
    }
    if c[x] == 1 {
        return d[x]
    }
    c[x] = 1

    d[x] = min(f(x - 1) + abs(h[x] - h[x-1]), f(x - 2) + abs(h[x] - h[x-2]))
    return d[x]
}

print(f(n-1))