import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {


       // BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n];

        for(int i=0; i<n; i++){
            arr[i] = sc.nextInt();
        }

        int a = 0;
        int b = Math.abs(arr[1]-arr[0]);

        if(n==2){
            System.out.println(b);
            System.exit(0);
        }

        int c = 0;

        for(int i=2;i<n;i++) {
            c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a);
            a = b;
            b = c;
        }

        System.out.println(c);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) throws IOException {


       // BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n];

        for(int i=0; i<n; i++){
            arr[i] = sc.nextInt();
        }

        int a = 0;
        int b = Math.abs(arr[1]-arr[0]);

        if(n==2){
            System.out.println(b);
            System.exit(0);
        }

        int c = 0;

        for(int i=2;i<n;i++) {
            c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a);
            a = b;
            b = c;
        }

        System.out.println(c);
    }
} Main public static void main(String[] args) throws IOException {


       // BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n];

        for(int i=0; i<n; i++){
            arr[i] = sc.nextInt();
        }

        int a = 0;
        int b = Math.abs(arr[1]-arr[0]);

        if(n==2){
            System.out.println(b);
            System.exit(0);
        }

        int c = 0;

        for(int i=2;i<n;i++) {
            c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a);
            a = b;
            b = c;
        }

        System.out.println(c);
    } main {


       // BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n];

        for(int i=0; i<n; i++){
            arr[i] = sc.nextInt();
        }

        int a = 0;
        int b = Math.abs(arr[1]-arr[0]);

        if(n==2){
            System.out.println(b);
            System.exit(0);
        }

        int c = 0;

        for(int i=2;i<n;i++) {
            c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a);
            a = b;
            b = c;
        }

        System.out.println(c);
    } 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]; arr new int[n] n for(int i=0; i<n; i++){
            arr[i] = sc.nextInt();
        } int i=0; int i=0; i 0 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 a = 0; a 0 int b = Math.abs(arr[1]-arr[0]); b Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 if(n==2){
            System.out.println(b);
            System.exit(0);
        } n==2 n 2 {
            System.out.println(b);
            System.exit(0);
        } System.out.println(b) System.out.println System.out System System.out b System.exit(0) System.exit System 0 int c = 0; c 0 for(int i=2;i<n;i++) {
            c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a);
            a = b;
            b = c;
        } int i=2; int i=2; i 2 i<n i n i++ i++ i {
            c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a);
            a = b;
            b = c;
        } {
            c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a);
            a = b;
            b = c;
        } c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a) c Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a) Math.min Math Math.abs(arr[i]-arr[i-1])+b 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 b Math.abs(arr[i]-arr[i-2])+a 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 a a = b a b b = c b c System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {

    public static void main(String[] args) throws IOException {


       // BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n];

        for(int i=0; i<n; i++){
            arr[i] = sc.nextInt();
        }

        int a = 0;
        int b = Math.abs(arr[1]-arr[0]);

        if(n==2){
            System.out.println(b);
            System.exit(0);
        }

        int c = 0;

        for(int i=2;i<n;i++) {
            c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a);
            a = b;
            b = c;
        }

        System.out.println(c);
    }
} public class Main {

    public static void main(String[] args) throws IOException {


       // BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n];

        for(int i=0; i<n; i++){
            arr[i] = sc.nextInt();
        }

        int a = 0;
        int b = Math.abs(arr[1]-arr[0]);

        if(n==2){
            System.out.println(b);
            System.exit(0);
        }

        int c = 0;

        for(int i=2;i<n;i++) {
            c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a);
            a = b;
            b = c;
        }

        System.out.println(c);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {


       // BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n];

        for(int i=0; i<n; i++){
            arr[i] = sc.nextInt();
        }

        int a = 0;
        int b = Math.abs(arr[1]-arr[0]);

        if(n==2){
            System.out.println(b);
            System.exit(0);
        }

        int c = 0;

        for(int i=2;i<n;i++) {
            c = Math.min(Math.abs(arr[i]-arr[i-1])+b, Math.abs(arr[i]-arr[i-2])+a);
            a = b;
            b = c;
        }

        System.out.println(c);
    }
}