

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		int dp[] = new int[n];
		dp[1] = Math.abs(input[1] - input[0]);
		for(int i = 2; i < n; i++){
			dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2]));
		}

		System.out.println(dp[n - 1]);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		int dp[] = new int[n];
		dp[1] = Math.abs(input[1] - input[0]);
		for(int i = 2; i < n; i++){
			dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2]));
		}

		System.out.println(dp[n - 1]);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		int dp[] = new int[n];
		dp[1] = Math.abs(input[1] - input[0]);
		for(int i = 2; i < n; i++){
			dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2]));
		}

		System.out.println(dp[n - 1]);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		int dp[] = new int[n];
		dp[1] = Math.abs(input[1] - input[0]);
		for(int i = 2; i < n; i++){
			dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2]));
		}

		System.out.println(dp[n - 1]);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int input[] = new int[n]; input new int[n] n for(int i = 0; i < n; i++){
			input[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			input[i] = sc.nextInt();
		} {
			input[i] = sc.nextInt();
		} input[i] = sc.nextInt() input[i] input i sc.nextInt() sc.nextInt sc int dp[] = new int[n]; dp new int[n] n dp[1] = Math.abs(input[1] - input[0]) dp[1] dp 1 Math.abs(input[1] - input[0]) Math.abs Math input[1] - input[0] input[1] input 1 input[0] input 0 for(int i = 2; i < n; i++){
			dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2]));
		} int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
			dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2]));
		} {
			dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2]));
		} dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2])) dp[i] dp i Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2])) Math.min Math dp[i - 1] + Math.abs(input[i] - input[i - 1]) dp[i - 1] dp i - 1 i 1 Math.abs(input[i] - input[i - 1]) Math.abs Math input[i] - input[i - 1] input[i] input i input[i - 1] input i - 1 i 1 dp[i - 2] + Math.abs(input[i] - input[i - 2]) dp[i - 2] dp i - 2 i 2 Math.abs(input[i] - input[i - 2]) Math.abs Math input[i] - input[i - 2] input[i] input i input[i - 2] input i - 2 i 2 System.out.println(dp[n - 1]) System.out.println System.out System System.out dp[n - 1] dp n - 1 n 1 String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		int dp[] = new int[n];
		dp[1] = Math.abs(input[1] - input[0]);
		for(int i = 2; i < n; i++){
			dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2]));
		}

		System.out.println(dp[n - 1]);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		int dp[] = new int[n];
		dp[1] = Math.abs(input[1] - input[0]);
		for(int i = 2; i < n; i++){
			dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2]));
		}

		System.out.println(dp[n - 1]);
	}

} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		int dp[] = new int[n];
		dp[1] = Math.abs(input[1] - input[0]);
		for(int i = 2; i < n; i++){
			dp[i] = Math.min(dp[i - 1] + Math.abs(input[i] - input[i - 1]), dp[i - 2] + Math.abs(input[i] - input[i - 2]));
		}

		System.out.println(dp[n - 1]);
	}

}
