
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;


public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		long[]a = input(n);
		long[] dp = new long[n];
		for(int i =1 ; i < n ;i++) {
			long temp = Math.abs(a[i]-a[i-1]) + dp[i-1];
			if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]);
			dp[i]=temp  ;
		}
		System.out.println(dp[n-1]);
	}
	public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.PrintWriter; PrintWriter java.io import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		long[]a = input(n);
		long[] dp = new long[n];
		for(int i =1 ; i < n ;i++) {
			long temp = Math.abs(a[i]-a[i-1]) + dp[i-1];
			if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]);
			dp[i]=temp  ;
		}
		System.out.println(dp[n-1]);
	}
	public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	}

} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		long[]a = input(n);
		long[] dp = new long[n];
		for(int i =1 ; i < n ;i++) {
			long temp = Math.abs(a[i]-a[i-1]) + dp[i-1];
			if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]);
			dp[i]=temp  ;
		}
		System.out.println(dp[n-1]);
	} main {
		int n = sc.nextInt();
		long[]a = input(n);
		long[] dp = new long[n];
		for(int i =1 ; i < n ;i++) {
			long temp = Math.abs(a[i]-a[i-1]) + dp[i-1];
			if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]);
			dp[i]=temp  ;
		}
		System.out.println(dp[n-1]);
	} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long[]a = input(n); a input(n) input n long[] dp = new long[n]; dp new long[n] n for(int i =1 ; i < n ;i++) {
			long temp = Math.abs(a[i]-a[i-1]) + dp[i-1];
			if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]);
			dp[i]=temp  ;
		} int i =1 ; int i =1 ; i 1 i < n i n i++ i++ i {
			long temp = Math.abs(a[i]-a[i-1]) + dp[i-1];
			if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]);
			dp[i]=temp  ;
		} {
			long temp = Math.abs(a[i]-a[i-1]) + dp[i-1];
			if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]);
			dp[i]=temp  ;
		} long temp = Math.abs(a[i]-a[i-1]) + dp[i-1]; temp Math.abs(a[i]-a[i-1]) + dp[i-1] 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 dp[i-1] dp i-1 i 1 if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]); i>1 i 1 temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]) temp Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]) Math.min Math temp Math.abs(a[i] - a[i-2] )+ dp[i-2] 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 dp[i-2] dp i-2 i 2 dp[i]=temp dp[i] dp i temp System.out.println(dp[n-1]) System.out.println System.out System System.out dp[n-1] dp n-1 n 1 String[] args args public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	} input {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	} long[] arr = new long[n]; arr new long[n] n for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			arr[i] = sc.nextLong();
		} {
			arr[i] = sc.nextLong();
		} arr[i] = sc.nextLong() arr[i] arr i sc.nextLong() sc.nextLong sc return arr; arr int n n public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		long[]a = input(n);
		long[] dp = new long[n];
		for(int i =1 ; i < n ;i++) {
			long temp = Math.abs(a[i]-a[i-1]) + dp[i-1];
			if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]);
			dp[i]=temp  ;
		}
		System.out.println(dp[n-1]);
	}
	public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	}

} public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		long[]a = input(n);
		long[] dp = new long[n];
		for(int i =1 ; i < n ;i++) {
			long temp = Math.abs(a[i]-a[i-1]) + dp[i-1];
			if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]);
			dp[i]=temp  ;
		}
		System.out.println(dp[n-1]);
	}
	public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	}

} Main

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;


public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		long[]a = input(n);
		long[] dp = new long[n];
		for(int i =1 ; i < n ;i++) {
			long temp = Math.abs(a[i]-a[i-1]) + dp[i-1];
			if(i>1)temp = Math.min(temp, Math.abs(a[i] - a[i-2] )+ dp[i-2]);
			dp[i]=temp  ;
		}
		System.out.println(dp[n-1]);
	}
	public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	}

}
