import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		}
		int[] cost = new int[n];
		cost[0] = 0;
		cost[1] = Math.abs(h[0] - h[1]);
		int tmp1;
		int tmp2;
		for(int i=2;i<n;i++) {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		}
		
		System.out.println(cost[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();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		}
		int[] cost = new int[n];
		cost[0] = 0;
		cost[1] = Math.abs(h[0] - h[1]);
		int tmp1;
		int tmp2;
		for(int i=2;i<n;i++) {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		}
		
		System.out.println(cost[n-1]);
		

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		}
		int[] cost = new int[n];
		cost[0] = 0;
		cost[1] = Math.abs(h[0] - h[1]);
		int tmp1;
		int tmp2;
		for(int i=2;i<n;i++) {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		}
		
		System.out.println(cost[n-1]);
		

	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		}
		int[] cost = new int[n];
		cost[0] = 0;
		cost[1] = Math.abs(h[0] - h[1]);
		int tmp1;
		int tmp2;
		for(int i=2;i<n;i++) {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		}
		
		System.out.println(cost[n-1]);
		

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] h = new int[n]; h new int[n] n for(int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			h[i] = sc.nextInt();
		} {
			h[i] = sc.nextInt();
		} h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc int[] cost = new int[n]; cost new int[n] n cost[0] = 0 cost[0] cost 0 0 cost[1] = Math.abs(h[0] - h[1]) cost[1] cost 1 Math.abs(h[0] - h[1]) Math.abs Math h[0] - h[1] h[0] h 0 h[1] h 1 int tmp1; tmp1 int tmp2; tmp2 for(int i=2;i<n;i++) {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		} int i=2; int i=2; i 2 i<n i n i++ i++ i {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		} {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		} tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1] tmp1 Math.abs(h[i-1] - h[i]) + cost[i-1] Math.abs(h[i-1] - h[i]) Math.abs Math h[i-1] - h[i] h[i-1] h i-1 i 1 h[i] h i cost[i-1] cost i-1 i 1 tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2] tmp2 Math.abs(h[i-2] - h[i]) + cost[i-2] Math.abs(h[i-2] - h[i]) Math.abs Math h[i-2] - h[i] h[i-2] h i-2 i 2 h[i] h i cost[i-2] cost i-2 i 2 cost[i] = Math.min(tmp1, tmp2) cost[i] cost i Math.min(tmp1, tmp2) Math.min Math tmp1 tmp2 System.out.println(cost[n-1]) System.out.println System.out System System.out cost[n-1] cost 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();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		}
		int[] cost = new int[n];
		cost[0] = 0;
		cost[1] = Math.abs(h[0] - h[1]);
		int tmp1;
		int tmp2;
		for(int i=2;i<n;i++) {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		}
		
		System.out.println(cost[n-1]);
		

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		}
		int[] cost = new int[n];
		cost[0] = 0;
		cost[1] = Math.abs(h[0] - h[1]);
		int tmp1;
		int tmp2;
		for(int i=2;i<n;i++) {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		}
		
		System.out.println(cost[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();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		}
		int[] cost = new int[n];
		cost[0] = 0;
		cost[1] = Math.abs(h[0] - h[1]);
		int tmp1;
		int tmp2;
		for(int i=2;i<n;i++) {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		}
		
		System.out.println(cost[n-1]);
		

	}

}
