import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;



public class Main {

	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7;
	static ArrayList<Integer> gr[];
	static int ar[];
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	//static long dp[];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
			int n=sc.nextInt();
			
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		}

	}
	
	static long solve(int n) {
		long dp[]=new long[n+1];
		dp[0]=0;
		dp[2]=Math.abs(ar[1]-ar[0]);
		for(int i=3;i<=n;i++) {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		}
		return dp[n];
		
	}


} import java.io.IOException; IOException java.io import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7;
	static ArrayList<Integer> gr[];
	static int ar[];
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	//static long dp[];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
			int n=sc.nextInt();
			
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		}

	}
	
	static long solve(int n) {
		long dp[]=new long[n+1];
		dp[0]=0;
		dp[2]=Math.abs(ar[1]-ar[0]);
		for(int i=3;i<=n;i++) {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		}
		return dp[n];
		
	}


} Main //	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7; mod (int)1e9+7 (int)1e9 7 static ArrayList<Integer> gr[]; gr static int ar[]; ar static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static int pri[] = new int[(int) 1e6 + 5]; pri new int[(int) 1e6 + 5] (int) 1e6 + 5 (int) 1e6 5 static StringBuilder out = new StringBuilder(); out new StringBuilder() public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
			int n=sc.nextInt();
			
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		}

	} main {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
			int n=sc.nextInt();
			
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		}

	} int t =1; t 1 while (t-- > 0) {
			int n=sc.nextInt();
			
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		} t-- > 0 t-- t 0 {
			int n=sc.nextInt();
			
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		} int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc ar=new int[n] ar new int[n] n for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			} int i=0; int i=0; i 0 i<n i n i++ i++ i {
				ar[i]=sc.nextInt();
			} {
				ar[i]=sc.nextInt();
			} ar[i]=sc.nextInt() ar[i] ar i sc.nextInt() sc.nextInt sc System.out.println(solve(n)) System.out.println System.out System System.out solve(n) solve n String[] args args static long solve(int n) {
		long dp[]=new long[n+1];
		dp[0]=0;
		dp[2]=Math.abs(ar[1]-ar[0]);
		for(int i=3;i<=n;i++) {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		}
		return dp[n];
		
	} solve {
		long dp[]=new long[n+1];
		dp[0]=0;
		dp[2]=Math.abs(ar[1]-ar[0]);
		for(int i=3;i<=n;i++) {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		}
		return dp[n];
		
	} long dp[]=new long[n+1]; dp new long[n+1] n+1 n 1 dp[0]=0 dp[0] dp 0 0 dp[2]=Math.abs(ar[1]-ar[0]) dp[2] dp 2 Math.abs(ar[1]-ar[0]) Math.abs Math ar[1]-ar[0] ar[1] ar 1 ar[0] ar 0 for(int i=3;i<=n;i++) {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		} int i=3; int i=3; i 3 i<=n i n i++ i++ i {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		} {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		} dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3]))) dp[i] dp i (long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3]))) Math.min Math dp[i-1]+Math.abs(ar[i-1]-ar[i-2]) dp[i-1] dp i-1 i 1 Math.abs(ar[i-1]-ar[i-2]) Math.abs Math ar[i-1]-ar[i-2] ar[i-1] ar i-1 i 1 ar[i-2] ar i-2 i 2 dp[i-2]+Math.abs(ar[i-1]-ar[i-3]) dp[i-2] dp i-2 i 2 Math.abs(ar[i-1]-ar[i-3]) Math.abs Math ar[i-1]-ar[i-3] ar[i-1] ar i-1 i 1 ar[i-3] ar i-3 i 3 return dp[n]; dp[n] dp n int n n public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	} pair int id; id int ans; ans pair(int x, int y) {

			id = x;
			ans = y;

		} pair {

			id = x;
			ans = y;

		} id = x id x ans = y ans y int x x int y y public pair() {

		} pair {

		} public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		} compareTo {
			// TODO Auto-generated method stub

			return this.id - o.id;
		} return this.id - o.id; this.id - o.id this.id this this.id o.id o o.id pair o o Comparable public class Main {

	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7;
	static ArrayList<Integer> gr[];
	static int ar[];
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	//static long dp[];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
			int n=sc.nextInt();
			
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		}

	}
	
	static long solve(int n) {
		long dp[]=new long[n+1];
		dp[0]=0;
		dp[2]=Math.abs(ar[1]-ar[0]);
		for(int i=3;i<=n;i++) {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		}
		return dp[n];
		
	}


} public class Main {

	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7;
	static ArrayList<Integer> gr[];
	static int ar[];
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	//static long dp[];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
			int n=sc.nextInt();
			
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		}

	}
	
	static long solve(int n) {
		long dp[]=new long[n+1];
		dp[0]=0;
		dp[2]=Math.abs(ar[1]-ar[0]);
		for(int i=3;i<=n;i++) {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		}
		return dp[n];
		
	}


} Main
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;



public class Main {

	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7;
	static ArrayList<Integer> gr[];
	static int ar[];
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	//static long dp[];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
			int n=sc.nextInt();
			
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		}

	}
	
	static long solve(int n) {
		long dp[]=new long[n+1];
		dp[0]=0;
		dp[2]=Math.abs(ar[1]-ar[0]);
		for(int i=3;i<=n;i++) {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		}
		return dp[n];
		
	}


}