import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] height = new int[n];
        for(int i = 0; i < n; i++){
            height[i] = scanner.nextInt();
        }
        System.out.println(new Main().f(n, height));
    }

    public int f(int n, int[] height) {
        int pre = 0;
        int cur = 0;
        if(n <= 1)
            return 0;
        pre = 0;
        cur = Math.abs(height[1] - height[0]);
        for(int i = 2; i < n; i++){
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        }
        return cur;
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] height = new int[n];
        for(int i = 0; i < n; i++){
            height[i] = scanner.nextInt();
        }
        System.out.println(new Main().f(n, height));
    }

    public int f(int n, int[] height) {
        int pre = 0;
        int cur = 0;
        if(n <= 1)
            return 0;
        pre = 0;
        cur = Math.abs(height[1] - height[0]);
        for(int i = 2; i < n; i++){
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        }
        return cur;
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] height = new int[n];
        for(int i = 0; i < n; i++){
            height[i] = scanner.nextInt();
        }
        System.out.println(new Main().f(n, height));
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] height = new int[n];
        for(int i = 0; i < n; i++){
            height[i] = scanner.nextInt();
        }
        System.out.println(new Main().f(n, height));
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int[] height = new int[n]; height new int[n] n for(int i = 0; i < n; i++){
            height[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            height[i] = scanner.nextInt();
        } {
            height[i] = scanner.nextInt();
        } height[i] = scanner.nextInt() height[i] height i scanner.nextInt() scanner.nextInt scanner System.out.println(new Main().f(n, height)) System.out.println System.out System System.out new Main().f(n, height) new Main().f new Main() n height String[] args args public int f(int n, int[] height) {
        int pre = 0;
        int cur = 0;
        if(n <= 1)
            return 0;
        pre = 0;
        cur = Math.abs(height[1] - height[0]);
        for(int i = 2; i < n; i++){
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        }
        return cur;
    } f {
        int pre = 0;
        int cur = 0;
        if(n <= 1)
            return 0;
        pre = 0;
        cur = Math.abs(height[1] - height[0]);
        for(int i = 2; i < n; i++){
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        }
        return cur;
    } int pre = 0; pre 0 int cur = 0; cur 0 if(n <= 1)
            return 0; n <= 1 n 1 return 0; 0 pre = 0 pre 0 cur = Math.abs(height[1] - height[0]) cur Math.abs(height[1] - height[0]) Math.abs Math height[1] - height[0] height[1] height 1 height[0] height 0 for(int i = 2; i < n; i++){
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        } int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        } {
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        } int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2])); t Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2])) Math.min Math cur + Math.abs(height[i] - height[i-1]) cur Math.abs(height[i] - height[i-1]) Math.abs Math height[i] - height[i-1] height[i] height i height[i-1] height i-1 i 1 pre + Math.abs(height[i] - height[i-2]) pre Math.abs(height[i] - height[i-2]) Math.abs Math height[i] - height[i-2] height[i] height i height[i-2] height i-2 i 2 pre = cur pre cur cur = t cur t return cur; cur int n n int[] height height public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] height = new int[n];
        for(int i = 0; i < n; i++){
            height[i] = scanner.nextInt();
        }
        System.out.println(new Main().f(n, height));
    }

    public int f(int n, int[] height) {
        int pre = 0;
        int cur = 0;
        if(n <= 1)
            return 0;
        pre = 0;
        cur = Math.abs(height[1] - height[0]);
        for(int i = 2; i < n; i++){
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        }
        return cur;
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] height = new int[n];
        for(int i = 0; i < n; i++){
            height[i] = scanner.nextInt();
        }
        System.out.println(new Main().f(n, height));
    }

    public int f(int n, int[] height) {
        int pre = 0;
        int cur = 0;
        if(n <= 1)
            return 0;
        pre = 0;
        cur = Math.abs(height[1] - height[0]);
        for(int i = 2; i < n; i++){
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        }
        return cur;
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] height = new int[n];
        for(int i = 0; i < n; i++){
            height[i] = scanner.nextInt();
        }
        System.out.println(new Main().f(n, height));
    }

    public int f(int n, int[] height) {
        int pre = 0;
        int cur = 0;
        if(n <= 1)
            return 0;
        pre = 0;
        cur = Math.abs(height[1] - height[0]);
        for(int i = 2; i < n; i++){
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        }
        return cur;
    }
}
