import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int h1 = scanner.nextInt();
        int h2 = scanner.nextInt();
        int dp1 = 0;
        int dp2 = Math.abs(h2 - h1);
        for (int i = 2; i < n; i++) {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        }
        System.out.println(dp2);
    }
} 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 h1 = scanner.nextInt();
        int h2 = scanner.nextInt();
        int dp1 = 0;
        int dp2 = Math.abs(h2 - h1);
        for (int i = 2; i < n; i++) {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        }
        System.out.println(dp2);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int h1 = scanner.nextInt();
        int h2 = scanner.nextInt();
        int dp1 = 0;
        int dp2 = Math.abs(h2 - h1);
        for (int i = 2; i < n; i++) {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        }
        System.out.println(dp2);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int h1 = scanner.nextInt();
        int h2 = scanner.nextInt();
        int dp1 = 0;
        int dp2 = Math.abs(h2 - h1);
        for (int i = 2; i < n; i++) {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        }
        System.out.println(dp2);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int h1 = scanner.nextInt(); h1 scanner.nextInt() scanner.nextInt scanner int h2 = scanner.nextInt(); h2 scanner.nextInt() scanner.nextInt scanner int dp1 = 0; dp1 0 int dp2 = Math.abs(h2 - h1); dp2 Math.abs(h2 - h1) Math.abs Math h2 - h1 h2 h1 for (int i = 2; i < n; i++) {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        } int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        } {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        } int h3 = scanner.nextInt(); h3 scanner.nextInt() scanner.nextInt scanner int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2)); dp3 Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2)) Math.min Math dp1 + Math.abs(h3 - h1) dp1 Math.abs(h3 - h1) Math.abs Math h3 - h1 h3 h1 dp2 + Math.abs(h3 - h2) dp2 Math.abs(h3 - h2) Math.abs Math h3 - h2 h3 h2 h1 = h2 h1 h2 h2 = h3 h2 h3 dp1 = dp2 dp1 dp2 dp2 = dp3 dp2 dp3 System.out.println(dp2) System.out.println System.out System System.out dp2 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int h1 = scanner.nextInt();
        int h2 = scanner.nextInt();
        int dp1 = 0;
        int dp2 = Math.abs(h2 - h1);
        for (int i = 2; i < n; i++) {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        }
        System.out.println(dp2);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int h1 = scanner.nextInt();
        int h2 = scanner.nextInt();
        int dp1 = 0;
        int dp2 = Math.abs(h2 - h1);
        for (int i = 2; i < n; i++) {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        }
        System.out.println(dp2);
    }
} 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 h1 = scanner.nextInt();
        int h2 = scanner.nextInt();
        int dp1 = 0;
        int dp2 = Math.abs(h2 - h1);
        for (int i = 2; i < n; i++) {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        }
        System.out.println(dp2);
    }
}
