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

public class Main {
    public static void main(String[] args) {
        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[] map = new int[n];
        Arrays.fill(map, -1);

        map[n-1] = 0;
        for (int i = n-2; i >= 0; i--) {
            map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1];
            if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            }
        }
        System.out.println(map[0]);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays 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];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int[] map = new int[n];
        Arrays.fill(map, -1);

        map[n-1] = 0;
        for (int i = n-2; i >= 0; i--) {
            map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1];
            if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            }
        }
        System.out.println(map[0]);
    }
} Main public static void main(String[] args) {
        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[] map = new int[n];
        Arrays.fill(map, -1);

        map[n-1] = 0;
        for (int i = n-2; i >= 0; i--) {
            map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1];
            if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            }
        }
        System.out.println(map[0]);
    } main {
        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[] map = new int[n];
        Arrays.fill(map, -1);

        map[n-1] = 0;
        for (int i = n-2; i >= 0; i--) {
            map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1];
            if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            }
        }
        System.out.println(map[0]);
    } 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[] map = new int[n]; map new int[n] n Arrays.fill(map, -1) Arrays.fill Arrays map -1 1 map[n-1] = 0 map[n-1] map n-1 n 1 0 for (int i = n-2; i >= 0; i--) {
            map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1];
            if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            }
        } int i = n-2; int i = n-2; i n-2 n 2 i >= 0 i 0 i-- i-- i {
            map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1];
            if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            }
        } {
            map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1];
            if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            }
        } map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1] map[i] map i Math.abs(arr[i+1]-arr[i]) + map[i+1] Math.abs(arr[i+1]-arr[i]) Math.abs Math arr[i+1]-arr[i] arr[i+1] arr i+1 i 1 arr[i] arr i map[i+1] map i+1 i 1 if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            } i+2 < n i+2 i 2 n {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            } map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]) map[i] map i Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]) Math.min Math map[i] map i Math.abs(arr[i+2]-arr[i]) + map[i+2] Math.abs(arr[i+2]-arr[i]) Math.abs Math arr[i+2]-arr[i] arr[i+2] arr i+2 i 2 arr[i] arr i map[i+2] map i+2 i 2 System.out.println(map[0]) System.out.println System.out System System.out map[0] map 0 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];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int[] map = new int[n];
        Arrays.fill(map, -1);

        map[n-1] = 0;
        for (int i = n-2; i >= 0; i--) {
            map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1];
            if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            }
        }
        System.out.println(map[0]);
    }
} public class Main {
    public static void main(String[] args) {
        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[] map = new int[n];
        Arrays.fill(map, -1);

        map[n-1] = 0;
        for (int i = n-2; i >= 0; i--) {
            map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1];
            if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            }
        }
        System.out.println(map[0]);
    }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        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[] map = new int[n];
        Arrays.fill(map, -1);

        map[n-1] = 0;
        for (int i = n-2; i >= 0; i--) {
            map[i] = Math.abs(arr[i+1]-arr[i]) + map[i+1];
            if (i+2 < n) {
                map[i] = Math.min(map[i], Math.abs(arr[i+2]-arr[i]) + map[i+2]);
            }
        }
        System.out.println(map[0]);
    }
}
