

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] h = new int[n];
		int[] cost = new int[n];
		
		for(int i = 0; i < h.length; i++) {
			h[i] = scan.nextInt();
		}
		
		for(int i = 0; i < h.length; i++) {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		}
		
		scan.close();
		/*
		 * for(int i = 0; i < cost.length;i++) { System.out.println(cost[i]); }
		 */
		
		System.out.println(cost[cost.length-1]);
		
	}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] h = new int[n];
		int[] cost = new int[n];
		
		for(int i = 0; i < h.length; i++) {
			h[i] = scan.nextInt();
		}
		
		for(int i = 0; i < h.length; i++) {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		}
		
		scan.close();
		/*
		 * for(int i = 0; i < cost.length;i++) { System.out.println(cost[i]); }
		 */
		
		System.out.println(cost[cost.length-1]);
		
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] h = new int[n];
		int[] cost = new int[n];
		
		for(int i = 0; i < h.length; i++) {
			h[i] = scan.nextInt();
		}
		
		for(int i = 0; i < h.length; i++) {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		}
		
		scan.close();
		/*
		 * for(int i = 0; i < cost.length;i++) { System.out.println(cost[i]); }
		 */
		
		System.out.println(cost[cost.length-1]);
		
	} main {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] h = new int[n];
		int[] cost = new int[n];
		
		for(int i = 0; i < h.length; i++) {
			h[i] = scan.nextInt();
		}
		
		for(int i = 0; i < h.length; i++) {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		}
		
		scan.close();
		/*
		 * for(int i = 0; i < cost.length;i++) { System.out.println(cost[i]); }
		 */
		
		System.out.println(cost[cost.length-1]);
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] h = new int[n]; h new int[n] n int[] cost = new int[n]; cost new int[n] n for(int i = 0; i < h.length; i++) {
			h[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i < h.length i h.length h h.length i++ i++ i {
			h[i] = scan.nextInt();
		} {
			h[i] = scan.nextInt();
		} h[i] = scan.nextInt() h[i] h i scan.nextInt() scan.nextInt scan for(int i = 0; i < h.length; i++) {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		} int i = 0; int i = 0; i 0 i < h.length i h.length h h.length i++ i++ i {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		} {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		} if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			} i == 0 i 0 {
				cost[i] = 0;
			} cost[i] = 0 cost[i] cost i 0 if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			} i == 1 i 1 {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			} cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1] cost[i] cost i Math.abs(h[i] - h[i-1]) + cost[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 cost[i-1] cost i-1 i 1 {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			} cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2] cost[i] cost i Math.abs(h[i] - h[i-2]) + cost[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 cost[i-2] cost i-2 i 2 if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				} cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1] cost[i] cost i Math.abs(h[i] - h[i-1]) + cost[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 cost[i-1] cost i-1 i 1 {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				} cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1] cost[i] cost i Math.abs(h[i] - h[i-1]) + cost[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 cost[i-1] cost i-1 i 1 scan.close() scan.close scan System.out.println(cost[cost.length-1]) System.out.println System.out System System.out cost[cost.length-1] cost cost.length-1 cost.length cost cost.length 1 String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] h = new int[n];
		int[] cost = new int[n];
		
		for(int i = 0; i < h.length; i++) {
			h[i] = scan.nextInt();
		}
		
		for(int i = 0; i < h.length; i++) {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		}
		
		scan.close();
		/*
		 * for(int i = 0; i < cost.length;i++) { System.out.println(cost[i]); }
		 */
		
		System.out.println(cost[cost.length-1]);
		
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] h = new int[n];
		int[] cost = new int[n];
		
		for(int i = 0; i < h.length; i++) {
			h[i] = scan.nextInt();
		}
		
		for(int i = 0; i < h.length; i++) {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		}
		
		scan.close();
		/*
		 * for(int i = 0; i < cost.length;i++) { System.out.println(cost[i]); }
		 */
		
		System.out.println(cost[cost.length-1]);
		
	}

} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] h = new int[n];
		int[] cost = new int[n];
		
		for(int i = 0; i < h.length; i++) {
			h[i] = scan.nextInt();
		}
		
		for(int i = 0; i < h.length; i++) {
			if(i == 0) {
				cost[i] = 0;
			}else if(i == 1) {
				cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
			}else {
				cost[i] = Math.abs(h[i] - h[i-2]) + cost[i-2];
				if(cost[i] > Math.abs(h[i] - h[i-1]) + cost[i-1]) {
					cost[i] = Math.abs(h[i] - h[i-1]) + cost[i-1];
				}
			}
		}
		
		scan.close();
		/*
		 * for(int i = 0; i < cost.length;i++) { System.out.println(cost[i]); }
		 */
		
		System.out.println(cost[cost.length-1]);
		
	}

}
