import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
				Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] H = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		}
		
		int[] result = new int[N+1];
		result[0] = 0;
		result[1] = Math.abs(H[1] - H[0]);
		for(int i = 2; i < N; i++) {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		}
		System.out.println(result[N-1]);
    }
} import java.util.*; util.* java import java.util.function.*; function.* java.util import java.math.*; math.* java public class Main {
    public static void main(String[] args){
				Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] H = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		}
		
		int[] result = new int[N+1];
		result[0] = 0;
		result[1] = Math.abs(H[1] - H[0]);
		for(int i = 2; i < N; i++) {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		}
		System.out.println(result[N-1]);
    }
} Main public static void main(String[] args){
				Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] H = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		}
		
		int[] result = new int[N+1];
		result[0] = 0;
		result[1] = Math.abs(H[1] - H[0]);
		for(int i = 2; i < N; i++) {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		}
		System.out.println(result[N-1]);
    } main {
				Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] H = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		}
		
		int[] result = new int[N+1];
		result[0] = 0;
		result[1] = Math.abs(H[1] - H[0]);
		for(int i = 2; i < N; i++) {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		}
		System.out.println(result[N-1]);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int N = s.nextInt(); N s.nextInt() s.nextInt s int[] H = new int[N]; H new int[N] N for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			H[i] = s.nextInt();
		} {
			H[i] = s.nextInt();
		} H[i] = s.nextInt() H[i] H i s.nextInt() s.nextInt s int[] result = new int[N+1]; result new int[N+1] N+1 N 1 result[0] = 0 result[0] result 0 0 result[1] = Math.abs(H[1] - H[0]) result[1] result 1 Math.abs(H[1] - H[0]) Math.abs Math H[1] - H[0] H[1] H 1 H[0] H 0 for(int i = 2; i < N; i++) {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		} int i = 2; int i = 2; i 2 i < N i N i++ i++ i {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		} {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		} result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2])) result[i] result i Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2])) Math.min Math result[i - 1] + Math.abs(H[i] - H[i - 1]) result[i - 1] result 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 result[i - 2] + Math.abs(H[i] - H[i - 2]) result[i - 2] result 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 System.out.println(result[N-1]) System.out.println System.out System System.out result[N-1] result N-1 N 1 String[] args args public class Main {
    public static void main(String[] args){
				Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] H = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		}
		
		int[] result = new int[N+1];
		result[0] = 0;
		result[1] = Math.abs(H[1] - H[0]);
		for(int i = 2; i < N; i++) {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		}
		System.out.println(result[N-1]);
    }
} public class Main {
    public static void main(String[] args){
				Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] H = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		}
		
		int[] result = new int[N+1];
		result[0] = 0;
		result[1] = Math.abs(H[1] - H[0]);
		for(int i = 2; i < N; i++) {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		}
		System.out.println(result[N-1]);
    }
} Main
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
				Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] H = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		}
		
		int[] result = new int[N+1];
		result[0] = 0;
		result[1] = Math.abs(H[1] - H[0]);
		for(int i = 2; i < N; i++) {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		}
		System.out.println(result[N-1]);
    }
}