import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.math;

void main()
{
    int N = readln.chomp.to!int;
    int[] h = readln.split.to!(int[]);

    int[] cost = new int[N];
    cost[0] = 0;
    cost[1] = abs(h[1] - h[0]);
    foreach (i; 2..N){
        int c0 = cost[i - 2] + abs(h[i] - h[i - 2]);
        int c1 = cost[i - 1] + abs(h[i] - h[i - 1]);
        if (c0 < c1) cost[i] = c0;
        else cost[i] = c1;
    }

    writeln(cost[$ - 1]);
}

