import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static int minCost(int stones[]) {
		int cost[] = new int[stones.length];
		cost[0] = 0;
		cost[1] = Math.abs(stones[1] - stones[0]);
		for (int i = 2; i < stones.length; i++) {
			cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]);
		}
		return cost[stones.length - 1];
	}

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.valueOf(br.readLine());
		int stones[] = new int[n];
		String array[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			stones[i] = Integer.valueOf(array[i]);
		}
		System.out.println("" + minCost(stones));

	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static int minCost(int stones[]) {
		int cost[] = new int[stones.length];
		cost[0] = 0;
		cost[1] = Math.abs(stones[1] - stones[0]);
		for (int i = 2; i < stones.length; i++) {
			cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]);
		}
		return cost[stones.length - 1];
	}

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.valueOf(br.readLine());
		int stones[] = new int[n];
		String array[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			stones[i] = Integer.valueOf(array[i]);
		}
		System.out.println("" + minCost(stones));

	}

} Main public static int minCost(int stones[]) {
		int cost[] = new int[stones.length];
		cost[0] = 0;
		cost[1] = Math.abs(stones[1] - stones[0]);
		for (int i = 2; i < stones.length; i++) {
			cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]);
		}
		return cost[stones.length - 1];
	} minCost {
		int cost[] = new int[stones.length];
		cost[0] = 0;
		cost[1] = Math.abs(stones[1] - stones[0]);
		for (int i = 2; i < stones.length; i++) {
			cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]);
		}
		return cost[stones.length - 1];
	} int cost[] = new int[stones.length]; cost new int[stones.length] stones.length stones stones.length cost[0] = 0 cost[0] cost 0 0 cost[1] = Math.abs(stones[1] - stones[0]) cost[1] cost 1 Math.abs(stones[1] - stones[0]) Math.abs Math stones[1] - stones[0] stones[1] stones 1 stones[0] stones 0 for (int i = 2; i < stones.length; i++) {
			cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]);
		} int i = 2; int i = 2; i 2 i < stones.length i stones.length stones stones.length i++ i++ i {
			cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]);
		} {
			cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]);
		} cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]) cost[i] cost i Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]) Math.min Math Math.abs(stones[i - 1] - stones[i]) + cost[i - 1] Math.abs(stones[i - 1] - stones[i]) Math.abs Math stones[i - 1] - stones[i] stones[i - 1] stones i - 1 i 1 stones[i] stones i cost[i - 1] cost i - 1 i 1 Math.abs(stones[i] - stones[i - 2]) + cost[i - 2] Math.abs(stones[i] - stones[i - 2]) Math.abs Math stones[i] - stones[i - 2] stones[i] stones i stones[i - 2] stones i - 2 i 2 cost[i - 2] cost i - 2 i 2 return cost[stones.length - 1]; cost[stones.length - 1] cost stones.length - 1 stones.length stones stones.length 1 int stones[] stones public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.valueOf(br.readLine());
		int stones[] = new int[n];
		String array[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			stones[i] = Integer.valueOf(array[i]);
		}
		System.out.println("" + minCost(stones));

	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.valueOf(br.readLine());
		int stones[] = new int[n];
		String array[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			stones[i] = Integer.valueOf(array[i]);
		}
		System.out.println("" + minCost(stones));

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = Integer.valueOf(br.readLine()); n Integer.valueOf(br.readLine()) Integer.valueOf Integer br.readLine() br.readLine br int stones[] = new int[n]; stones new int[n] n String array[] = br.readLine().split(" "); array br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for (int i = 0; i < n; i++) {
			stones[i] = Integer.valueOf(array[i]);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			stones[i] = Integer.valueOf(array[i]);
		} {
			stones[i] = Integer.valueOf(array[i]);
		} stones[i] = Integer.valueOf(array[i]) stones[i] stones i Integer.valueOf(array[i]) Integer.valueOf Integer array[i] array i System.out.println("" + minCost(stones)) System.out.println System.out System System.out "" + minCost(stones) "" minCost(stones) minCost stones String[] args args public class Main {

	public static int minCost(int stones[]) {
		int cost[] = new int[stones.length];
		cost[0] = 0;
		cost[1] = Math.abs(stones[1] - stones[0]);
		for (int i = 2; i < stones.length; i++) {
			cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]);
		}
		return cost[stones.length - 1];
	}

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.valueOf(br.readLine());
		int stones[] = new int[n];
		String array[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			stones[i] = Integer.valueOf(array[i]);
		}
		System.out.println("" + minCost(stones));

	}

} public class Main {

	public static int minCost(int stones[]) {
		int cost[] = new int[stones.length];
		cost[0] = 0;
		cost[1] = Math.abs(stones[1] - stones[0]);
		for (int i = 2; i < stones.length; i++) {
			cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]);
		}
		return cost[stones.length - 1];
	}

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.valueOf(br.readLine());
		int stones[] = new int[n];
		String array[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			stones[i] = Integer.valueOf(array[i]);
		}
		System.out.println("" + minCost(stones));

	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static int minCost(int stones[]) {
		int cost[] = new int[stones.length];
		cost[0] = 0;
		cost[1] = Math.abs(stones[1] - stones[0]);
		for (int i = 2; i < stones.length; i++) {
			cost[i] = Math.min(Math.abs(stones[i - 1] - stones[i]) + cost[i - 1],
					Math.abs(stones[i] - stones[i - 2]) + cost[i - 2]);
		}
		return cost[stones.length - 1];
	}

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.valueOf(br.readLine());
		int stones[] = new int[n];
		String array[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			stones[i] = Integer.valueOf(array[i]);
		}
		System.out.println("" + minCost(stones));

	}

}