import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		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[N-1] =0;
		for(int i=N-2; i>=0;i--) {
			if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			}				
		}
		pw.println(cost[0]);
		// end

		sc.close();
		pw.close();
	}
} import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		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[N-1] =0;
		for(int i=N-2; i>=0;i--) {
			if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			}				
		}
		pw.println(cost[0]);
		// end

		sc.close();
		pw.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		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[N-1] =0;
		for(int i=N-2; i>=0;i--) {
			if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			}				
		}
		pw.println(cost[0]);
		// end

		sc.close();
		pw.close();
	} main {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		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[N-1] =0;
		for(int i=N-2; i>=0;i--) {
			if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			}				
		}
		pw.println(cost[0]);
		// end

		sc.close();
		pw.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) 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[N-1] =0 cost[N-1] cost N-1 N 1 0 for(int i=N-2; i>=0;i--) {
			if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			}				
		} int i=N-2; int i=N-2; i N-2 N 2 i>=0 i 0 i-- i-- i {
			if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			}				
		} {
			if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			}				
		} if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			} i == N-2 i N-2 N 2 cost[i]=Math.abs(h[i+1]-h[i]) cost[i] cost i 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] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			} cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i])) cost[i] cost i Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i])) Math.min Math cost[i+1]+Math.abs(h[i+1]-h[i]) cost[i+1] cost i+1 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+2]+Math.abs(h[i+2]-h[i]) cost[i+2] cost i+2 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 pw.println(cost[0]) pw.println pw cost[0] cost 0 sc.close() sc.close sc pw.close() pw.close pw String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		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[N-1] =0;
		for(int i=N-2; i>=0;i--) {
			if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			}				
		}
		pw.println(cost[0]);
		// end

		sc.close();
		pw.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		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[N-1] =0;
		for(int i=N-2; i>=0;i--) {
			if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			}				
		}
		pw.println(cost[0]);
		// end

		sc.close();
		pw.close();
	}
} Main
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		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[N-1] =0;
		for(int i=N-2; i>=0;i--) {
			if(i == N-2)cost[i]=Math.abs(h[i+1]-h[i]);
			else {
				cost[i] = Math.min(cost[i+1]+Math.abs(h[i+1]-h[i]), cost[i+2]+Math.abs(h[i+2]-h[i]));
			}				
		}
		pw.println(cost[0]);
		// end

		sc.close();
		pw.close();
	}
}
