/////////package Educ_DP;

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int a=s.nextInt();
        s.nextLine();
        String[]l=s.nextLine().split(" ");
        int[] list=new int[l.length];
        for (int i=0;i<list.length;i++){
            list[i]=Integer.parseInt(l[i]);
        }
        int[] dp=new int[list.length];
        dp[dp.length-1]=0;
        dp[dp.length-2]=Math.abs(list[list.length-1]-list[list.length-2]);
        for (int i=dp.length-3;i>=0;i--){
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        }
        System.out.println(dp[0]);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int a=s.nextInt();
        s.nextLine();
        String[]l=s.nextLine().split(" ");
        int[] list=new int[l.length];
        for (int i=0;i<list.length;i++){
            list[i]=Integer.parseInt(l[i]);
        }
        int[] dp=new int[list.length];
        dp[dp.length-1]=0;
        dp[dp.length-2]=Math.abs(list[list.length-1]-list[list.length-2]);
        for (int i=dp.length-3;i>=0;i--){
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        }
        System.out.println(dp[0]);
    }
} Main public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int a=s.nextInt();
        s.nextLine();
        String[]l=s.nextLine().split(" ");
        int[] list=new int[l.length];
        for (int i=0;i<list.length;i++){
            list[i]=Integer.parseInt(l[i]);
        }
        int[] dp=new int[list.length];
        dp[dp.length-1]=0;
        dp[dp.length-2]=Math.abs(list[list.length-1]-list[list.length-2]);
        for (int i=dp.length-3;i>=0;i--){
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        }
        System.out.println(dp[0]);
    } main {
        Scanner s=new Scanner(System.in);
        int a=s.nextInt();
        s.nextLine();
        String[]l=s.nextLine().split(" ");
        int[] list=new int[l.length];
        for (int i=0;i<list.length;i++){
            list[i]=Integer.parseInt(l[i]);
        }
        int[] dp=new int[list.length];
        dp[dp.length-1]=0;
        dp[dp.length-2]=Math.abs(list[list.length-1]-list[list.length-2]);
        for (int i=dp.length-3;i>=0;i--){
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        }
        System.out.println(dp[0]);
    } Scanner s=new Scanner(System.in); s new Scanner(System.in) int a=s.nextInt(); a s.nextInt() s.nextInt s s.nextLine() s.nextLine s String[]l=s.nextLine().split(" "); l s.nextLine().split(" ") s.nextLine().split s.nextLine() s.nextLine s " " int[] list=new int[l.length]; list new int[l.length] l.length l l.length for (int i=0;i<list.length;i++){
            list[i]=Integer.parseInt(l[i]);
        } int i=0; int i=0; i 0 i<list.length i list.length list list.length i++ i++ i {
            list[i]=Integer.parseInt(l[i]);
        } {
            list[i]=Integer.parseInt(l[i]);
        } list[i]=Integer.parseInt(l[i]) list[i] list i Integer.parseInt(l[i]) Integer.parseInt Integer l[i] l i int[] dp=new int[list.length]; dp new int[list.length] list.length list list.length dp[dp.length-1]=0 dp[dp.length-1] dp dp.length-1 dp.length dp dp.length 1 0 dp[dp.length-2]=Math.abs(list[list.length-1]-list[list.length-2]) dp[dp.length-2] dp dp.length-2 dp.length dp dp.length 2 Math.abs(list[list.length-1]-list[list.length-2]) Math.abs Math list[list.length-1]-list[list.length-2] list[list.length-1] list list.length-1 list.length list list.length 1 list[list.length-2] list list.length-2 list.length list list.length 2 for (int i=dp.length-3;i>=0;i--){
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        } int i=dp.length-3; int i=dp.length-3; i dp.length-3 dp.length dp dp.length 3 i>=0 i 0 i-- i-- i {
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        } {
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        } dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1])) dp[i] dp i Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1])) Math.min Math dp[i+2]+Math.abs(list[i]-list[i+2]) dp[i+2] dp i+2 i 2 Math.abs(list[i]-list[i+2]) Math.abs Math list[i]-list[i+2] list[i] list i list[i+2] list i+2 i 2 dp[i+1]+Math.abs(list[i]-list[i+1]) dp[i+1] dp i+1 i 1 Math.abs(list[i]-list[i+1]) Math.abs Math list[i]-list[i+1] list[i] list i list[i+1] list i+1 i 1 System.out.println(dp[0]) System.out.println System.out System System.out dp[0] dp 0 String[] args args public class Main {
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int a=s.nextInt();
        s.nextLine();
        String[]l=s.nextLine().split(" ");
        int[] list=new int[l.length];
        for (int i=0;i<list.length;i++){
            list[i]=Integer.parseInt(l[i]);
        }
        int[] dp=new int[list.length];
        dp[dp.length-1]=0;
        dp[dp.length-2]=Math.abs(list[list.length-1]-list[list.length-2]);
        for (int i=dp.length-3;i>=0;i--){
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        }
        System.out.println(dp[0]);
    }
} public class Main {
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int a=s.nextInt();
        s.nextLine();
        String[]l=s.nextLine().split(" ");
        int[] list=new int[l.length];
        for (int i=0;i<list.length;i++){
            list[i]=Integer.parseInt(l[i]);
        }
        int[] dp=new int[list.length];
        dp[dp.length-1]=0;
        dp[dp.length-2]=Math.abs(list[list.length-1]-list[list.length-2]);
        for (int i=dp.length-3;i>=0;i--){
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        }
        System.out.println(dp[0]);
    }
} Main
/////////package Educ_DP;

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int a=s.nextInt();
        s.nextLine();
        String[]l=s.nextLine().split(" ");
        int[] list=new int[l.length];
        for (int i=0;i<list.length;i++){
            list[i]=Integer.parseInt(l[i]);
        }
        int[] dp=new int[list.length];
        dp[dp.length-1]=0;
        dp[dp.length-2]=Math.abs(list[list.length-1]-list[list.length-2]);
        for (int i=dp.length-3;i>=0;i--){
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        }
        System.out.println(dp[0]);
    }
}
