import java.util.Arrays;
import java.util.Scanner;

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

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