import java.util.*;
import java.io.*;

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());
		String[] s = br.readLine().split(" ");
		int[] h = new int[n];
		for (int i = 0 ; i < n; i++) 
			h[i] = Integer.parseInt(s[i]);
		
		if (n == 2) {
			System.out.println(h[1]-h[0]);
			return;
		}
		
		int[] dp = new int[n];
		dp[1] = Math.abs(h[1]-h[0]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		}
		System.out.print(dp[n-1]);
	}

} import java.util.*; util.* java 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 n = Integer.parseInt(br.readLine());
		String[] s = br.readLine().split(" ");
		int[] h = new int[n];
		for (int i = 0 ; i < n; i++) 
			h[i] = Integer.parseInt(s[i]);
		
		if (n == 2) {
			System.out.println(h[1]-h[0]);
			return;
		}
		
		int[] dp = new int[n];
		dp[1] = Math.abs(h[1]-h[0]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		}
		System.out.print(dp[n-1]);
	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] s = br.readLine().split(" ");
		int[] h = new int[n];
		for (int i = 0 ; i < n; i++) 
			h[i] = Integer.parseInt(s[i]);
		
		if (n == 2) {
			System.out.println(h[1]-h[0]);
			return;
		}
		
		int[] dp = new int[n];
		dp[1] = Math.abs(h[1]-h[0]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		}
		System.out.print(dp[n-1]);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] s = br.readLine().split(" ");
		int[] h = new int[n];
		for (int i = 0 ; i < n; i++) 
			h[i] = Integer.parseInt(s[i]);
		
		if (n == 2) {
			System.out.println(h[1]-h[0]);
			return;
		}
		
		int[] dp = new int[n];
		dp[1] = Math.abs(h[1]-h[0]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		}
		System.out.print(dp[n-1]);
	} 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 String[] s = br.readLine().split(" "); s br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] h = new int[n]; h new int[n] n for (int i = 0 ; i < n; i++) 
			h[i] = Integer.parseInt(s[i]); int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i h[i] = Integer.parseInt(s[i]); h[i] = Integer.parseInt(s[i]) h[i] h i Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i if (n == 2) {
			System.out.println(h[1]-h[0]);
			return;
		} n == 2 n 2 {
			System.out.println(h[1]-h[0]);
			return;
		} System.out.println(h[1]-h[0]) System.out.println System.out System System.out h[1]-h[0] h[1] h 1 h[0] h 0 return; int[] dp = new int[n]; dp new int[n] n dp[1] = Math.abs(h[1]-h[0]) dp[1] dp 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++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		} int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		} {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		} dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i])) dp[i] dp i Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i])) Math.min Math dp[i-1] + Math.abs(h[i-1]-h[i]) dp[i-1] dp 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 dp[i-2] + Math.abs(h[i-2]-h[i]) dp[i-2] dp 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 System.out.print(dp[n-1]) System.out.print System.out System System.out dp[n-1] dp n-1 n 1 String[] args args 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());
		String[] s = br.readLine().split(" ");
		int[] h = new int[n];
		for (int i = 0 ; i < n; i++) 
			h[i] = Integer.parseInt(s[i]);
		
		if (n == 2) {
			System.out.println(h[1]-h[0]);
			return;
		}
		
		int[] dp = new int[n];
		dp[1] = Math.abs(h[1]-h[0]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		}
		System.out.print(dp[n-1]);
	}

} 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());
		String[] s = br.readLine().split(" ");
		int[] h = new int[n];
		for (int i = 0 ; i < n; i++) 
			h[i] = Integer.parseInt(s[i]);
		
		if (n == 2) {
			System.out.println(h[1]-h[0]);
			return;
		}
		
		int[] dp = new int[n];
		dp[1] = Math.abs(h[1]-h[0]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		}
		System.out.print(dp[n-1]);
	}

} Main
import java.util.*;
import java.io.*;

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());
		String[] s = br.readLine().split(" ");
		int[] h = new int[n];
		for (int i = 0 ; i < n; i++) 
			h[i] = Integer.parseInt(s[i]);
		
		if (n == 2) {
			System.out.println(h[1]-h[0]);
			return;
		}
		
		int[] dp = new int[n];
		dp[1] = Math.abs(h[1]-h[0]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i-1]-h[i]), dp[i-2] + Math.abs(h[i-2]-h[i]));
		}
		System.out.print(dp[n-1]);
	}

}
