import java.io.*;
 
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int line1 = Integer.parseInt(br.readLine());
		int[] array = new int[line1+1];
		String[] line2 = br.readLine().split(" ");
		for(int i = 0; i < line1 ; i++) {
			array[i+1] = Integer.parseInt(line2[i]);
		}
		System.out.println(metodo(line1, array));
	}
	
	public static int metodo(int N, int[] array) {
		int[] array1 = new int[N+1];
		array1[2] = Math.abs(array[1] - array[2]);
		for(int i = 3; i <= N; i++) {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			}		
		return array1[N];
	}
} import java.io.*; io.* java public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int line1 = Integer.parseInt(br.readLine());
		int[] array = new int[line1+1];
		String[] line2 = br.readLine().split(" ");
		for(int i = 0; i < line1 ; i++) {
			array[i+1] = Integer.parseInt(line2[i]);
		}
		System.out.println(metodo(line1, array));
	}
	
	public static int metodo(int N, int[] array) {
		int[] array1 = new int[N+1];
		array1[2] = Math.abs(array[1] - array[2]);
		for(int i = 3; i <= N; i++) {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			}		
		return array1[N];
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int line1 = Integer.parseInt(br.readLine());
		int[] array = new int[line1+1];
		String[] line2 = br.readLine().split(" ");
		for(int i = 0; i < line1 ; i++) {
			array[i+1] = Integer.parseInt(line2[i]);
		}
		System.out.println(metodo(line1, array));
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int line1 = Integer.parseInt(br.readLine());
		int[] array = new int[line1+1];
		String[] line2 = br.readLine().split(" ");
		for(int i = 0; i < line1 ; i++) {
			array[i+1] = Integer.parseInt(line2[i]);
		}
		System.out.println(metodo(line1, array));
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int line1 = Integer.parseInt(br.readLine()); line1 Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int[] array = new int[line1+1]; array new int[line1+1] line1+1 line1 1 String[] line2 = br.readLine().split(" "); line2 br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for(int i = 0; i < line1 ; i++) {
			array[i+1] = Integer.parseInt(line2[i]);
		} int i = 0; int i = 0; i 0 i < line1 i line1 i++ i++ i {
			array[i+1] = Integer.parseInt(line2[i]);
		} {
			array[i+1] = Integer.parseInt(line2[i]);
		} array[i+1] = Integer.parseInt(line2[i]) array[i+1] array i+1 i 1 Integer.parseInt(line2[i]) Integer.parseInt Integer line2[i] line2 i System.out.println(metodo(line1, array)) System.out.println System.out System System.out metodo(line1, array) metodo line1 array String[] args args public static int metodo(int N, int[] array) {
		int[] array1 = new int[N+1];
		array1[2] = Math.abs(array[1] - array[2]);
		for(int i = 3; i <= N; i++) {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			}		
		return array1[N];
	} metodo {
		int[] array1 = new int[N+1];
		array1[2] = Math.abs(array[1] - array[2]);
		for(int i = 3; i <= N; i++) {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			}		
		return array1[N];
	} int[] array1 = new int[N+1]; array1 new int[N+1] N+1 N 1 array1[2] = Math.abs(array[1] - array[2]) array1[2] array1 2 Math.abs(array[1] - array[2]) Math.abs Math array[1] - array[2] array[1] array 1 array[2] array 2 for(int i = 3; i <= N; i++) {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			} int i = 3; int i = 3; i 3 i <= N i N i++ i++ i {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			} {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			} array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i])) array1[i] array1 i Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i])) Math.min Math array1[i-1] + Math.abs(array[i-1] - array[i]) array1[i-1] array1 i-1 i 1 Math.abs(array[i-1] - array[i]) Math.abs Math array[i-1] - array[i] array[i-1] array i-1 i 1 array[i] array i array1[i-2] + Math.abs(array[i-2]-array[i]) array1[i-2] array1 i-2 i 2 Math.abs(array[i-2]-array[i]) Math.abs Math array[i-2]-array[i] array[i-2] array i-2 i 2 array[i] array i return array1[N]; array1[N] array1 N int N N int[] array array public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int line1 = Integer.parseInt(br.readLine());
		int[] array = new int[line1+1];
		String[] line2 = br.readLine().split(" ");
		for(int i = 0; i < line1 ; i++) {
			array[i+1] = Integer.parseInt(line2[i]);
		}
		System.out.println(metodo(line1, array));
	}
	
	public static int metodo(int N, int[] array) {
		int[] array1 = new int[N+1];
		array1[2] = Math.abs(array[1] - array[2]);
		for(int i = 3; i <= N; i++) {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			}		
		return array1[N];
	}
} public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int line1 = Integer.parseInt(br.readLine());
		int[] array = new int[line1+1];
		String[] line2 = br.readLine().split(" ");
		for(int i = 0; i < line1 ; i++) {
			array[i+1] = Integer.parseInt(line2[i]);
		}
		System.out.println(metodo(line1, array));
	}
	
	public static int metodo(int N, int[] array) {
		int[] array1 = new int[N+1];
		array1[2] = Math.abs(array[1] - array[2]);
		for(int i = 3; i <= N; i++) {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			}		
		return array1[N];
	}
} Main
import java.io.*;
 
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int line1 = Integer.parseInt(br.readLine());
		int[] array = new int[line1+1];
		String[] line2 = br.readLine().split(" ");
		for(int i = 0; i < line1 ; i++) {
			array[i+1] = Integer.parseInt(line2[i]);
		}
		System.out.println(metodo(line1, array));
	}
	
	public static int metodo(int N, int[] array) {
		int[] array1 = new int[N+1];
		array1[2] = Math.abs(array[1] - array[2]);
		for(int i = 3; i <= N; i++) {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			}		
		return array1[N];
	}
}