import java.util.*;
class Main {
    int[] arr;
    private int cost(int i, int j) {
    	return Math.abs(arr[i] - arr[j]);
	}

	private void run() {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) arr[i] = sc.nextInt();
        int[] dp = new int[N];
        dp[N-1] = 0;
        dp[N-2] = cost(N-2, N-1);
        for (int i = N - 3; i >= 0; i--) {
        	dp[i] = Math.min(dp[i+1]+ cost(i, i + 1), dp[i+2]+cost(i, i+2));
        }
		System.out.println(dp[0]);
    }
  
	public static void main(String[] args) {
    	Main m = new Main();
      	m.run();
	}
} import java.util.*; util.* java class Main {
    int[] arr;
    private int cost(int i, int j) {
    	return Math.abs(arr[i] - arr[j]);
	}

	private void run() {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) arr[i] = sc.nextInt();
        int[] dp = new int[N];
        dp[N-1] = 0;
        dp[N-2] = cost(N-2, N-1);
        for (int i = N - 3; i >= 0; i--) {
        	dp[i] = Math.min(dp[i+1]+ cost(i, i + 1), dp[i+2]+cost(i, i+2));
        }
		System.out.println(dp[0]);
    }
  
	public static void main(String[] args) {
    	Main m = new Main();
      	m.run();
	}
} Main int[] arr; arr private int cost(int i, int j) {
    	return Math.abs(arr[i] - arr[j]);
	} cost {
    	return Math.abs(arr[i] - arr[j]);
	} return Math.abs(arr[i] - arr[j]); Math.abs(arr[i] - arr[j]) Math.abs Math arr[i] - arr[j] arr[i] arr i arr[j] arr j int i i int j j private void run() {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) arr[i] = sc.nextInt();
        int[] dp = new int[N];
        dp[N-1] = 0;
        dp[N-2] = cost(N-2, N-1);
        for (int i = N - 3; i >= 0; i--) {
        	dp[i] = Math.min(dp[i+1]+ cost(i, i + 1), dp[i+2]+cost(i, i+2));
        }
		System.out.println(dp[0]);
    } run {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) arr[i] = sc.nextInt();
        int[] dp = new int[N];
        dp[N-1] = 0;
        dp[N-2] = cost(N-2, N-1);
        for (int i = N - 3; i >= 0; i--) {
        	dp[i] = Math.min(dp[i+1]+ cost(i, i + 1), dp[i+2]+cost(i, i+2));
        }
		System.out.println(dp[0]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc 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] arr i sc.nextInt() sc.nextInt sc int[] dp = new int[N]; dp new int[N] N dp[N-1] = 0 dp[N-1] dp N-1 N 1 0 dp[N-2] = cost(N-2, N-1) dp[N-2] dp N-2 N 2 cost(N-2, N-1) cost N-2 N 2 N-1 N 1 for (int i = N - 3; i >= 0; i--) {
        	dp[i] = Math.min(dp[i+1]+ cost(i, i + 1), dp[i+2]+cost(i, i+2));
        } int i = N - 3; int i = N - 3; i N - 3 N 3 i >= 0 i 0 i-- i-- i {
        	dp[i] = Math.min(dp[i+1]+ cost(i, i + 1), dp[i+2]+cost(i, i+2));
        } {
        	dp[i] = Math.min(dp[i+1]+ cost(i, i + 1), dp[i+2]+cost(i, i+2));
        } dp[i] = Math.min(dp[i+1]+ cost(i, i + 1), dp[i+2]+cost(i, i+2)) dp[i] dp i Math.min(dp[i+1]+ cost(i, i + 1), dp[i+2]+cost(i, i+2)) Math.min Math dp[i+1]+ cost(i, i + 1) dp[i+1] dp i+1 i 1 cost(i, i + 1) cost i i + 1 i 1 dp[i+2]+cost(i, i+2) dp[i+2] dp i+2 i 2 cost(i, i+2) cost i i+2 i 2 System.out.println(dp[0]) System.out.println System.out System System.out dp[0] dp 0 public static void main(String[] args) {
    	Main m = new Main();
      	m.run();
	} main {
    	Main m = new Main();
      	m.run();
	} Main m = new Main(); m new Main() m.run() m.run m String[] args args
import java.util.*;
class Main {
    int[] arr;
    private int cost(int i, int j) {
    	return Math.abs(arr[i] - arr[j]);
	}

	private void run() {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) arr[i] = sc.nextInt();
        int[] dp = new int[N];
        dp[N-1] = 0;
        dp[N-2] = cost(N-2, N-1);
        for (int i = N - 3; i >= 0; i--) {
        	dp[i] = Math.min(dp[i+1]+ cost(i, i + 1), dp[i+2]+cost(i, i+2));
        }
		System.out.println(dp[0]);
    }
  
	public static void main(String[] args) {
    	Main m = new Main();
      	m.run();
	}
}
