import java.util.Scanner;

 class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] arr = new int[n];
        int[] dp = new int[n];
        for(int i=0;i<n;++i){
            arr[i]=input.nextInt();
        }
        if(n==0 || n==1)
            System.out.println("0");
        else {
            dp[1]=Math.abs(arr[1]-arr[0]);
            for (int i = 2; i < n; ++i) {
                int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                dp[i]=Math.min(val1,val2);
            }
        }
        System.out.println(dp[n-1]);

    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] arr = new int[n];
        int[] dp = new int[n];
        for(int i=0;i<n;++i){
            arr[i]=input.nextInt();
        }
        if(n==0 || n==1)
            System.out.println("0");
        else {
            dp[1]=Math.abs(arr[1]-arr[0]);
            for (int i = 2; i < n; ++i) {
                int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                dp[i]=Math.min(val1,val2);
            }
        }
        System.out.println(dp[n-1]);

    }
} Main public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] arr = new int[n];
        int[] dp = new int[n];
        for(int i=0;i<n;++i){
            arr[i]=input.nextInt();
        }
        if(n==0 || n==1)
            System.out.println("0");
        else {
            dp[1]=Math.abs(arr[1]-arr[0]);
            for (int i = 2; i < n; ++i) {
                int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                dp[i]=Math.min(val1,val2);
            }
        }
        System.out.println(dp[n-1]);

    } main {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] arr = new int[n];
        int[] dp = new int[n];
        for(int i=0;i<n;++i){
            arr[i]=input.nextInt();
        }
        if(n==0 || n==1)
            System.out.println("0");
        else {
            dp[1]=Math.abs(arr[1]-arr[0]);
            for (int i = 2; i < n; ++i) {
                int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                dp[i]=Math.min(val1,val2);
            }
        }
        System.out.println(dp[n-1]);

    } Scanner input = new Scanner(System.in); input new Scanner(System.in) int n = input.nextInt(); n input.nextInt() input.nextInt input int[] arr = new int[n]; arr new int[n] n int[] dp = new int[n]; dp new int[n] n for(int i=0;i<n;++i){
            arr[i]=input.nextInt();
        } int i=0; int i=0; i 0 i<n i n ++i ++i i {
            arr[i]=input.nextInt();
        } {
            arr[i]=input.nextInt();
        } arr[i]=input.nextInt() arr[i] arr i input.nextInt() input.nextInt input if(n==0 || n==1)
            System.out.println("0");
        else {
            dp[1]=Math.abs(arr[1]-arr[0]);
            for (int i = 2; i < n; ++i) {
                int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                dp[i]=Math.min(val1,val2);
            }
        } n==0 || n==1 n==0 n 0 n==1 n 1 System.out.println("0") System.out.println System.out System System.out "0" {
            dp[1]=Math.abs(arr[1]-arr[0]);
            for (int i = 2; i < n; ++i) {
                int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                dp[i]=Math.min(val1,val2);
            }
        } dp[1]=Math.abs(arr[1]-arr[0]) dp[1] dp 1 Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 for (int i = 2; i < n; ++i) {
                int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                dp[i]=Math.min(val1,val2);
            } int i = 2; int i = 2; i 2 i < n i n ++i ++i i {
                int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                dp[i]=Math.min(val1,val2);
            } {
                int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                dp[i]=Math.min(val1,val2);
            } int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]); val1 dp[i-1]+Math.abs(arr[i]-arr[i-1]) dp[i-1] dp i-1 i 1 Math.abs(arr[i]-arr[i-1]) Math.abs Math arr[i]-arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]); val2 dp[i-2]+Math.abs(arr[i]-arr[i-2]) dp[i-2] dp i-2 i 2 Math.abs(arr[i]-arr[i-2]) Math.abs Math arr[i]-arr[i-2] arr[i] arr i arr[i-2] arr i-2 i 2 dp[i]=Math.min(val1,val2) dp[i] dp i Math.min(val1,val2) Math.min Math val1 val2 System.out.println(dp[n-1]) System.out.println System.out System System.out dp[n-1] dp n-1 n 1 String[] args args
import java.util.Scanner;

 class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] arr = new int[n];
        int[] dp = new int[n];
        for(int i=0;i<n;++i){
            arr[i]=input.nextInt();
        }
        if(n==0 || n==1)
            System.out.println("0");
        else {
            dp[1]=Math.abs(arr[1]-arr[0]);
            for (int i = 2; i < n; ++i) {
                int val1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
                int val2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
                dp[i]=Math.min(val1,val2);
            }
        }
        System.out.println(dp[n-1]);

    }
}
