import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] dp = new long[n];
		long[] h = new long[n];
		for(int i = 0; i < n ; i++) {
			h[i] = sc.nextLong();
		}
		for(int i = 0 ; i < n ; i ++) {
			if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			}
		}

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

	}


}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] dp = new long[n];
		long[] h = new long[n];
		for(int i = 0; i < n ; i++) {
			h[i] = sc.nextLong();
		}
		for(int i = 0 ; i < n ; i ++) {
			if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			}
		}

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

	}


} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] dp = new long[n];
		long[] h = new long[n];
		for(int i = 0; i < n ; i++) {
			h[i] = sc.nextLong();
		}
		for(int i = 0 ; i < n ; i ++) {
			if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			}
		}

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

	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] dp = new long[n];
		long[] h = new long[n];
		for(int i = 0; i < n ; i++) {
			h[i] = sc.nextLong();
		}
		for(int i = 0 ; i < n ; i ++) {
			if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			}
		}

		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 long[] dp = new long[n]; dp new long[n] n long[] h = new long[n]; h new long[n] n for(int i = 0; i < n ; i++) {
			h[i] = sc.nextLong();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			h[i] = sc.nextLong();
		} {
			h[i] = sc.nextLong();
		} h[i] = sc.nextLong() h[i] h i sc.nextLong() sc.nextLong sc for(int i = 0 ; i < n ; i ++) {
			if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			}
		} int i = 0 ; int i = 0 ; i 0 i < n i n i ++ i ++ i {
			if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			}
		} {
			if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			}
		} if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			} i == 0 i 0 {
				dp[i] = 0;
			} dp[i] = 0 dp[i] dp i 0 if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			} i == 1 i 1 {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			} dp[i] = Math.abs(h[i] - h[i - 1]) dp[i] dp i Math.abs(h[i] - h[i - 1]) Math.abs Math h[i] - h[i - 1] h[i] h i h[i - 1] h i - 1 i 1 {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			} dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1])) dp[i] dp i Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1])) Math.min Math dp[i - 2] + Math.abs(h[i] - h[i - 2]) dp[i - 2] dp i - 2 i 2 Math.abs(h[i] - h[i - 2]) Math.abs Math h[i] - h[i - 2] h[i] h i h[i - 2] h i - 2 i 2 dp[i - 1] + Math.abs(h[i] - h[i - 1]) dp[i - 1] dp i - 1 i 1 Math.abs(h[i] - h[i - 1]) Math.abs Math h[i] - h[i - 1] h[i] h i h[i - 1] h i - 1 i 1 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) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] dp = new long[n];
		long[] h = new long[n];
		for(int i = 0; i < n ; i++) {
			h[i] = sc.nextLong();
		}
		for(int i = 0 ; i < n ; i ++) {
			if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			}
		}

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

	}


} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] dp = new long[n];
		long[] h = new long[n];
		for(int i = 0; i < n ; i++) {
			h[i] = sc.nextLong();
		}
		for(int i = 0 ; i < n ; i ++) {
			if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			}
		}

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

	}


} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] dp = new long[n];
		long[] h = new long[n];
		for(int i = 0; i < n ; i++) {
			h[i] = sc.nextLong();
		}
		for(int i = 0 ; i < n ; i ++) {
			if(i == 0) {
				dp[i] = 0;
			}
			else if(i == 1) {
				dp[i] = Math.abs(h[i] - h[i - 1]);
			}
			else {
				dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			}
		}

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

	}


}

