import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t =s.nextInt();
        int [] arr = new int[t];
        int [] minpatharr = new int[t];
        for(int i=0;i<t;i++)
            arr[i]=s.nextInt();
        minpatharr[0]=0;
        minpatharr[1]=Math.abs(arr[1]-arr[0]);
        for(int i=2;i<t;i++){
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        }
        System.out.println(minpatharr[t-1]);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t =s.nextInt();
        int [] arr = new int[t];
        int [] minpatharr = new int[t];
        for(int i=0;i<t;i++)
            arr[i]=s.nextInt();
        minpatharr[0]=0;
        minpatharr[1]=Math.abs(arr[1]-arr[0]);
        for(int i=2;i<t;i++){
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        }
        System.out.println(minpatharr[t-1]);
    }
} Main public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t =s.nextInt();
        int [] arr = new int[t];
        int [] minpatharr = new int[t];
        for(int i=0;i<t;i++)
            arr[i]=s.nextInt();
        minpatharr[0]=0;
        minpatharr[1]=Math.abs(arr[1]-arr[0]);
        for(int i=2;i<t;i++){
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        }
        System.out.println(minpatharr[t-1]);
    } main {
        Scanner s = new Scanner(System.in);
        int t =s.nextInt();
        int [] arr = new int[t];
        int [] minpatharr = new int[t];
        for(int i=0;i<t;i++)
            arr[i]=s.nextInt();
        minpatharr[0]=0;
        minpatharr[1]=Math.abs(arr[1]-arr[0]);
        for(int i=2;i<t;i++){
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        }
        System.out.println(minpatharr[t-1]);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int t =s.nextInt(); t s.nextInt() s.nextInt s int [] arr = new int[t]; arr new int[t] t int [] minpatharr = new int[t]; minpatharr new int[t] t for(int i=0;i<t;i++)
            arr[i]=s.nextInt(); int i=0; int i=0; i 0 i<t i t i++ i++ i arr[i]=s.nextInt(); arr[i]=s.nextInt() arr[i] arr i s.nextInt() s.nextInt s minpatharr[0]=0 minpatharr[0] minpatharr 0 0 minpatharr[1]=Math.abs(arr[1]-arr[0]) minpatharr[1] minpatharr 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<t;i++){
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        } int i=2; int i=2; i 2 i<t i t i++ i++ i {
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        } {
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        } minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]) minpatharr[i] minpatharr i Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]) Math.min Math Math.abs(arr[i]-arr[i-1])+minpatharr[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 minpatharr[i-1] minpatharr i-1 i 1 Math.abs(arr[i]-arr[i-2])+minpatharr[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 minpatharr[i-2] minpatharr i-2 i 2 System.out.println(minpatharr[t-1]) System.out.println System.out System System.out minpatharr[t-1] minpatharr t-1 t 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t =s.nextInt();
        int [] arr = new int[t];
        int [] minpatharr = new int[t];
        for(int i=0;i<t;i++)
            arr[i]=s.nextInt();
        minpatharr[0]=0;
        minpatharr[1]=Math.abs(arr[1]-arr[0]);
        for(int i=2;i<t;i++){
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        }
        System.out.println(minpatharr[t-1]);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t =s.nextInt();
        int [] arr = new int[t];
        int [] minpatharr = new int[t];
        for(int i=0;i<t;i++)
            arr[i]=s.nextInt();
        minpatharr[0]=0;
        minpatharr[1]=Math.abs(arr[1]-arr[0]);
        for(int i=2;i<t;i++){
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        }
        System.out.println(minpatharr[t-1]);
    }
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t =s.nextInt();
        int [] arr = new int[t];
        int [] minpatharr = new int[t];
        for(int i=0;i<t;i++)
            arr[i]=s.nextInt();
        minpatharr[0]=0;
        minpatharr[1]=Math.abs(arr[1]-arr[0]);
        for(int i=2;i<t;i++){
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        }
        System.out.println(minpatharr[t-1]);
    }
}
