import java.util.*;

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

        int dp[] = new int[n+1];
        dp[1] = 0;
        for(int i=2;i<=n;i++){
            int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1];
            int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2];
            dp[i] = Math.min(option1,option2);
        }

        System.out.println(dp[n]);

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

        int dp[] = new int[n+1];
        dp[1] = 0;
        for(int i=2;i<=n;i++){
            int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1];
            int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2];
            dp[i] = Math.min(option1,option2);
        }

        System.out.println(dp[n]);

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

        int dp[] = new int[n+1];
        dp[1] = 0;
        for(int i=2;i<=n;i++){
            int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1];
            int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2];
            dp[i] = Math.min(option1,option2);
        }

        System.out.println(dp[n]);

    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n+1];
        for(int i=1;i<=n;i++){
            arr[i] = sc.nextInt();
        }

        int dp[] = new int[n+1];
        dp[1] = 0;
        for(int i=2;i<=n;i++){
            int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1];
            int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2];
            dp[i] = Math.min(option1,option2);
        }

        System.out.println(dp[n]);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int arr[] = new int[n+1]; arr new int[n+1] n+1 n 1 for(int i=1;i<=n;i++){
            arr[i] = sc.nextInt();
        } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
            arr[i] = sc.nextInt();
        } {
            arr[i] = sc.nextInt();
        } arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc int dp[] = new int[n+1]; dp new int[n+1] n+1 n 1 dp[1] = 0 dp[1] dp 1 0 for(int i=2;i<=n;i++){
            int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1];
            int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2];
            dp[i] = Math.min(option1,option2);
        } int i=2; int i=2; i 2 i<=n i n i++ i++ i {
            int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1];
            int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2];
            dp[i] = Math.min(option1,option2);
        } {
            int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1];
            int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2];
            dp[i] = Math.min(option1,option2);
        } int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1]; option1 Math.abs(arr[i]-arr[i-1]) + dp[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 dp[i-1] dp i-1 i 1 int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2]; option2 (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2] (i == 2) i 2 Integer.MAX_VALUE Integer Integer.MAX_VALUE Math.abs(arr[i]-arr[i-2]) + dp[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-2] dp i-2 i 2 dp[i] = Math.min(option1,option2) dp[i] dp i Math.min(option1,option2) Math.min Math option1 option2 System.out.println(dp[n]) System.out.println System.out System System.out dp[n] dp n String args[] args public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n+1];
        for(int i=1;i<=n;i++){
            arr[i] = sc.nextInt();
        }

        int dp[] = new int[n+1];
        dp[1] = 0;
        for(int i=2;i<=n;i++){
            int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1];
            int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2];
            dp[i] = Math.min(option1,option2);
        }

        System.out.println(dp[n]);

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

        int dp[] = new int[n+1];
        dp[1] = 0;
        for(int i=2;i<=n;i++){
            int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1];
            int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2];
            dp[i] = Math.min(option1,option2);
        }

        System.out.println(dp[n]);

    }
} Main
import java.util.*;

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

        int dp[] = new int[n+1];
        dp[1] = 0;
        for(int i=2;i<=n;i++){
            int option1 = Math.abs(arr[i]-arr[i-1]) + dp[i-1];
            int option2 = (i == 2) ? Integer.MAX_VALUE :  Math.abs(arr[i]-arr[i-2]) + dp[i-2];
            dp[i] = Math.min(option1,option2);
        }

        System.out.println(dp[n]);

    }
}