import java.util.Scanner;

public class Main {

    public static int ans(int stones[], int n){
        int storage[] = new int[n+1];
        storage[1] = 0;
        for(int i=2; i<=n; i++){
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        }
        return storage[n];
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int stones[] = new int[n+1];
        for(int i=1; i<=n; i++){
            stones[i] = sc.nextInt();
        }
        System.out.println(ans(stones, n));
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static int ans(int stones[], int n){
        int storage[] = new int[n+1];
        storage[1] = 0;
        for(int i=2; i<=n; i++){
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        }
        return storage[n];
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int stones[] = new int[n+1];
        for(int i=1; i<=n; i++){
            stones[i] = sc.nextInt();
        }
        System.out.println(ans(stones, n));
    }
} Main public static int ans(int stones[], int n){
        int storage[] = new int[n+1];
        storage[1] = 0;
        for(int i=2; i<=n; i++){
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        }
        return storage[n];
    } ans {
        int storage[] = new int[n+1];
        storage[1] = 0;
        for(int i=2; i<=n; i++){
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        }
        return storage[n];
    } int storage[] = new int[n+1]; storage new int[n+1] n+1 n 1 storage[1] = 0 storage[1] storage 1 0 for(int i=2; i<=n; i++){
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        } int i=2; int i=2; i 2 i<=n i n i++ i++ i {
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        } {
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        } int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1]; option1 Math.abs(stones[i] - stones[i-1]) + storage[i-1] Math.abs(stones[i] - stones[i-1]) Math.abs Math stones[i] - stones[i-1] stones[i] stones i stones[i-1] stones i-1 i 1 storage[i-1] storage i-1 i 1 int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2]; option2 (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2] (i==2) i 2 Integer.MAX_VALUE Integer Integer.MAX_VALUE Math.abs(stones[i] - stones[i-2]) + storage[i-2] Math.abs(stones[i] - stones[i-2]) Math.abs Math stones[i] - stones[i-2] stones[i] stones i stones[i-2] stones i-2 i 2 storage[i-2] storage i-2 i 2 storage[i] = Math.min(option1, option2) storage[i] storage i Math.min(option1, option2) Math.min Math option1 option2 return storage[n]; storage[n] storage n int stones[] stones int n n public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int stones[] = new int[n+1];
        for(int i=1; i<=n; i++){
            stones[i] = sc.nextInt();
        }
        System.out.println(ans(stones, n));
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int stones[] = new int[n+1];
        for(int i=1; i<=n; i++){
            stones[i] = sc.nextInt();
        }
        System.out.println(ans(stones, n));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int stones[] = new int[n+1]; stones new int[n+1] n+1 n 1 for(int i=1; i<=n; i++){
            stones[i] = sc.nextInt();
        } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
            stones[i] = sc.nextInt();
        } {
            stones[i] = sc.nextInt();
        } stones[i] = sc.nextInt() stones[i] stones i sc.nextInt() sc.nextInt sc System.out.println(ans(stones, n)) System.out.println System.out System System.out ans(stones, n) ans stones n String args[] args public class Main {

    public static int ans(int stones[], int n){
        int storage[] = new int[n+1];
        storage[1] = 0;
        for(int i=2; i<=n; i++){
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        }
        return storage[n];
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int stones[] = new int[n+1];
        for(int i=1; i<=n; i++){
            stones[i] = sc.nextInt();
        }
        System.out.println(ans(stones, n));
    }
} public class Main {

    public static int ans(int stones[], int n){
        int storage[] = new int[n+1];
        storage[1] = 0;
        for(int i=2; i<=n; i++){
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        }
        return storage[n];
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int stones[] = new int[n+1];
        for(int i=1; i<=n; i++){
            stones[i] = sc.nextInt();
        }
        System.out.println(ans(stones, n));
    }
} Main
import java.util.Scanner;

public class Main {

    public static int ans(int stones[], int n){
        int storage[] = new int[n+1];
        storage[1] = 0;
        for(int i=2; i<=n; i++){
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        }
        return storage[n];
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int stones[] = new int[n+1];
        for(int i=1; i<=n; i++){
            stones[i] = sc.nextInt();
        }
        System.out.println(ans(stones, n));
    }
}