import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.Buffer;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		int[] H = new int[N+1];
		
		String[] S = br.readLine().split(" ");
		for(int i = 0; i < N ; i++) {
			H[i+1] = Integer.parseInt(S[i]);
		}
		System.out.println(minCostJump(N, H));
	}
	
	public static int minCostJump(int N, int[] H) {
		int[] cache = new int[N+1];
		
		cache[2] = Math.abs(H[1] - H[2]);
		for(int i = 3; i <= N; i++) {
			cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i]));
		}
		
		return cache[N];
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.nio.Buffer; Buffer java.nio public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		int[] H = new int[N+1];
		
		String[] S = br.readLine().split(" ");
		for(int i = 0; i < N ; i++) {
			H[i+1] = Integer.parseInt(S[i]);
		}
		System.out.println(minCostJump(N, H));
	}
	
	public static int minCostJump(int N, int[] H) {
		int[] cache = new int[N+1];
		
		cache[2] = Math.abs(H[1] - H[2]);
		for(int i = 3; i <= N; i++) {
			cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i]));
		}
		
		return cache[N];
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		int[] H = new int[N+1];
		
		String[] S = br.readLine().split(" ");
		for(int i = 0; i < N ; i++) {
			H[i+1] = Integer.parseInt(S[i]);
		}
		System.out.println(minCostJump(N, H));
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		int[] H = new int[N+1];
		
		String[] S = br.readLine().split(" ");
		for(int i = 0; i < N ; i++) {
			H[i+1] = Integer.parseInt(S[i]);
		}
		System.out.println(minCostJump(N, H));
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int N = Integer.parseInt(br.readLine()); N Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int[] H = new int[N+1]; H new int[N+1] N+1 N 1 String[] S = br.readLine().split(" "); S br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for(int i = 0; i < N ; i++) {
			H[i+1] = Integer.parseInt(S[i]);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			H[i+1] = Integer.parseInt(S[i]);
		} {
			H[i+1] = Integer.parseInt(S[i]);
		} H[i+1] = Integer.parseInt(S[i]) H[i+1] H i+1 i 1 Integer.parseInt(S[i]) Integer.parseInt Integer S[i] S i System.out.println(minCostJump(N, H)) System.out.println System.out System System.out minCostJump(N, H) minCostJump N H String[] args args public static int minCostJump(int N, int[] H) {
		int[] cache = new int[N+1];
		
		cache[2] = Math.abs(H[1] - H[2]);
		for(int i = 3; i <= N; i++) {
			cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i]));
		}
		
		return cache[N];
	} minCostJump {
		int[] cache = new int[N+1];
		
		cache[2] = Math.abs(H[1] - H[2]);
		for(int i = 3; i <= N; i++) {
			cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i]));
		}
		
		return cache[N];
	} int[] cache = new int[N+1]; cache new int[N+1] N+1 N 1 cache[2] = Math.abs(H[1] - H[2]) cache[2] cache 2 Math.abs(H[1] - H[2]) Math.abs Math H[1] - H[2] H[1] H 1 H[2] H 2 for(int i = 3; i <= N; i++) {
			cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i]));
		} int i = 3; int i = 3; i 3 i <= N i N i++ i++ i {
			cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i]));
		} {
			cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i]));
		} cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i])) cache[i] cache i Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i])) Math.min Math cache[i-1] + Math.abs(H[i-1] - H[i]) cache[i-1] cache 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 cache[i-2] + Math.abs(H[i-2]-H[i]) cache[i-2] cache 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 return cache[N]; cache[N] cache N int N N int[] H H public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		int[] H = new int[N+1];
		
		String[] S = br.readLine().split(" ");
		for(int i = 0; i < N ; i++) {
			H[i+1] = Integer.parseInt(S[i]);
		}
		System.out.println(minCostJump(N, H));
	}
	
	public static int minCostJump(int N, int[] H) {
		int[] cache = new int[N+1];
		
		cache[2] = Math.abs(H[1] - H[2]);
		for(int i = 3; i <= N; i++) {
			cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i]));
		}
		
		return cache[N];
	}
} public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		int[] H = new int[N+1];
		
		String[] S = br.readLine().split(" ");
		for(int i = 0; i < N ; i++) {
			H[i+1] = Integer.parseInt(S[i]);
		}
		System.out.println(minCostJump(N, H));
	}
	
	public static int minCostJump(int N, int[] H) {
		int[] cache = new int[N+1];
		
		cache[2] = Math.abs(H[1] - H[2]);
		for(int i = 3; i <= N; i++) {
			cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i]));
		}
		
		return cache[N];
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.Buffer;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		int[] H = new int[N+1];
		
		String[] S = br.readLine().split(" ");
		for(int i = 0; i < N ; i++) {
			H[i+1] = Integer.parseInt(S[i]);
		}
		System.out.println(minCostJump(N, H));
	}
	
	public static int minCostJump(int N, int[] H) {
		int[] cache = new int[N+1];
		
		cache[2] = Math.abs(H[1] - H[2]);
		for(int i = 3; i <= N; i++) {
			cache[i] = Math.min(cache[i-1] + Math.abs(H[i-1] - H[i]), cache[i-2] + Math.abs(H[i-2]-H[i]));
		}
		
		return cache[N];
	}
}
