import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(input[i]);
        }

        System.out.println(getMinCost(h));
    }

    private static int getMinCost(int[] h) {
        int[] cost = new int[h.length];
        cost[1] = Math.abs(h[1] - h[0]);

        for (int i = 2; i < h.length; i++) {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        }

        return cost[h.length-1];
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(input[i]);
        }

        System.out.println(getMinCost(h));
    }

    private static int getMinCost(int[] h) {
        int[] cost = new int[h.length];
        cost[1] = Math.abs(h[1] - h[0]);

        for (int i = 2; i < h.length; i++) {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        }

        return cost[h.length-1];
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(input[i]);
        }

        System.out.println(getMinCost(h));
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(input[i]);
        }

        System.out.println(getMinCost(h));
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int N = Integer.parseInt(br.readLine()); N Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] h = new int[N]; h new int[N] N for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(input[i]);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            h[i] = Integer.parseInt(input[i]);
        } {
            h[i] = Integer.parseInt(input[i]);
        } h[i] = Integer.parseInt(input[i]) h[i] h i Integer.parseInt(input[i]) Integer.parseInt Integer input[i] input i System.out.println(getMinCost(h)) System.out.println System.out System System.out getMinCost(h) getMinCost h String[] args args private static int getMinCost(int[] h) {
        int[] cost = new int[h.length];
        cost[1] = Math.abs(h[1] - h[0]);

        for (int i = 2; i < h.length; i++) {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        }

        return cost[h.length-1];
    } getMinCost {
        int[] cost = new int[h.length];
        cost[1] = Math.abs(h[1] - h[0]);

        for (int i = 2; i < h.length; i++) {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        }

        return cost[h.length-1];
    } int[] cost = new int[h.length]; cost new int[h.length] h.length h h.length cost[1] = Math.abs(h[1] - h[0]) cost[1] cost 1 Math.abs(h[1] - h[0]) Math.abs Math h[1] - h[0] h[1] h 1 h[0] h 0 for (int i = 2; i < h.length; i++) {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        } int i = 2; int i = 2; i 2 i < h.length i h.length h h.length i++ i++ i {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        } {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        } cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i])) cost[i] cost i Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i])) Math.min Math cost[i-2] + Math.abs(h[i-2] - h[i]) cost[i-2] cost i-2 i 2 Math.abs(h[i-2] - h[i]) Math.abs Math h[i-2] - h[i] h[i-2] h i-2 i 2 h[i] h i cost[i-1] + Math.abs(h[i-1] - h[i]) cost[i-1] cost i-1 i 1 Math.abs(h[i-1] - h[i]) Math.abs Math h[i-1] - h[i] h[i-1] h i-1 i 1 h[i] h i return cost[h.length-1]; cost[h.length-1] cost h.length-1 h.length h h.length 1 int[] h h public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(input[i]);
        }

        System.out.println(getMinCost(h));
    }

    private static int getMinCost(int[] h) {
        int[] cost = new int[h.length];
        cost[1] = Math.abs(h[1] - h[0]);

        for (int i = 2; i < h.length; i++) {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        }

        return cost[h.length-1];
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(input[i]);
        }

        System.out.println(getMinCost(h));
    }

    private static int getMinCost(int[] h) {
        int[] cost = new int[h.length];
        cost[1] = Math.abs(h[1] - h[0]);

        for (int i = 2; i < h.length; i++) {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        }

        return cost[h.length-1];
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(input[i]);
        }

        System.out.println(getMinCost(h));
    }

    private static int getMinCost(int[] h) {
        int[] cost = new int[h.length];
        cost[1] = Math.abs(h[1] - h[0]);

        for (int i = 2; i < h.length; i++) {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        }

        return cost[h.length-1];
    }
}
