import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		
		String[] input = br.readLine().split(" ");
		
		for (int i = 0; i < input.length; i++) {
			a[i] = Integer.parseInt(input[i]);
		}
		
		int ans = solve(a);
		
		System.out.println(ans);
	}

	private static int solve(int[] a) {
		
		int[] dp = new int[a.length];
		
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0] = 0;
		
		for (int i = 0; i < dp.length; i++) {
			
			if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1]));
			
			if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2]));
			
		}
		
		return dp[a.length-1];
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		
		String[] input = br.readLine().split(" ");
		
		for (int i = 0; i < input.length; i++) {
			a[i] = Integer.parseInt(input[i]);
		}
		
		int ans = solve(a);
		
		System.out.println(ans);
	}

	private static int solve(int[] a) {
		
		int[] dp = new int[a.length];
		
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0] = 0;
		
		for (int i = 0; i < dp.length; i++) {
			
			if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1]));
			
			if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2]));
			
		}
		
		return dp[a.length-1];
	}
} Main public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		
		String[] input = br.readLine().split(" ");
		
		for (int i = 0; i < input.length; i++) {
			a[i] = Integer.parseInt(input[i]);
		}
		
		int ans = solve(a);
		
		System.out.println(ans);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		
		String[] input = br.readLine().split(" ");
		
		for (int i = 0; i < input.length; i++) {
			a[i] = Integer.parseInt(input[i]);
		}
		
		int ans = solve(a);
		
		System.out.println(ans);
	} 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[] a = new int[n]; a new int[n] n String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for (int i = 0; i < input.length; i++) {
			a[i] = Integer.parseInt(input[i]);
		} int i = 0; int i = 0; i 0 i < input.length i input.length input input.length i++ i++ i {
			a[i] = Integer.parseInt(input[i]);
		} {
			a[i] = Integer.parseInt(input[i]);
		} a[i] = Integer.parseInt(input[i]) a[i] a i Integer.parseInt(input[i]) Integer.parseInt Integer input[i] input i int ans = solve(a); ans solve(a) solve a System.out.println(ans) System.out.println System.out System System.out ans String[] args args private static int solve(int[] a) {
		
		int[] dp = new int[a.length];
		
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0] = 0;
		
		for (int i = 0; i < dp.length; i++) {
			
			if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1]));
			
			if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2]));
			
		}
		
		return dp[a.length-1];
	} solve {
		
		int[] dp = new int[a.length];
		
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0] = 0;
		
		for (int i = 0; i < dp.length; i++) {
			
			if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1]));
			
			if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2]));
			
		}
		
		return dp[a.length-1];
	} int[] dp = new int[a.length]; dp new int[a.length] a.length a a.length Arrays.fill(dp, Integer.MAX_VALUE) Arrays.fill Arrays dp Integer.MAX_VALUE Integer Integer.MAX_VALUE dp[0] = 0 dp[0] dp 0 0 for (int i = 0; i < dp.length; i++) {
			
			if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1]));
			
			if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2]));
			
		} int i = 0; int i = 0; i 0 i < dp.length i dp.length dp dp.length i++ i++ i {
			
			if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1]));
			
			if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2]));
			
		} {
			
			if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1]));
			
			if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2]));
			
		} if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1])); (i+1)<a.length (i+1) i 1 a.length a a.length dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1])) dp[i+1] dp i+1 i 1 Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1])) Math.min Math dp[i+1] dp i+1 i 1 dp[i]+ Math.abs(a[i]-a[i+1]) dp[i] dp i Math.abs(a[i]-a[i+1]) Math.abs Math a[i]-a[i+1] a[i] a i a[i+1] a i+1 i 1 if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2])); (i+2)<a.length (i+2) i 2 a.length a a.length dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2])) dp[i+2] dp i+2 i 2 Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2])) Math.min Math dp[i+2] dp i+2 i 2 dp[i]+ Math.abs(a[i]-a[i+2]) dp[i] dp i Math.abs(a[i]-a[i+2]) Math.abs Math a[i]-a[i+2] a[i] a i a[i+2] a i+2 i 2 return dp[a.length-1]; dp[a.length-1] dp a.length-1 a.length a a.length 1 int[] a a public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		
		String[] input = br.readLine().split(" ");
		
		for (int i = 0; i < input.length; i++) {
			a[i] = Integer.parseInt(input[i]);
		}
		
		int ans = solve(a);
		
		System.out.println(ans);
	}

	private static int solve(int[] a) {
		
		int[] dp = new int[a.length];
		
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0] = 0;
		
		for (int i = 0; i < dp.length; i++) {
			
			if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1]));
			
			if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2]));
			
		}
		
		return dp[a.length-1];
	}
} public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		
		String[] input = br.readLine().split(" ");
		
		for (int i = 0; i < input.length; i++) {
			a[i] = Integer.parseInt(input[i]);
		}
		
		int ans = solve(a);
		
		System.out.println(ans);
	}

	private static int solve(int[] a) {
		
		int[] dp = new int[a.length];
		
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0] = 0;
		
		for (int i = 0; i < dp.length; i++) {
			
			if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1]));
			
			if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2]));
			
		}
		
		return dp[a.length-1];
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		
		String[] input = br.readLine().split(" ");
		
		for (int i = 0; i < input.length; i++) {
			a[i] = Integer.parseInt(input[i]);
		}
		
		int ans = solve(a);
		
		System.out.println(ans);
	}

	private static int solve(int[] a) {
		
		int[] dp = new int[a.length];
		
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0] = 0;
		
		for (int i = 0; i < dp.length; i++) {
			
			if((i+1)<a.length)
				dp[i+1] = Math.min(dp[i+1],dp[i]+ Math.abs(a[i]-a[i+1]));
			
			if((i+2)<a.length)
				dp[i+2] = Math.min(dp[i+2],dp[i]+ Math.abs(a[i]-a[i+2]));
			
		}
		
		return dp[a.length-1];
	}
}