

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int []arr=new int[n];
		int []dp= new int[n];
		for(int i=0;i<n;i++)
			arr[i]=in.nextInt();
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		}
		System.out.println(dp[n-1]);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int []arr=new int[n];
		int []dp= new int[n];
		for(int i=0;i<n;i++)
			arr[i]=in.nextInt();
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		}
		System.out.println(dp[n-1]);
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int []arr=new int[n];
		int []dp= new int[n];
		for(int i=0;i<n;i++)
			arr[i]=in.nextInt();
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		}
		System.out.println(dp[n-1]);
	} main {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int []arr=new int[n];
		int []dp= new int[n];
		for(int i=0;i<n;i++)
			arr[i]=in.nextInt();
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		}
		System.out.println(dp[n-1]);
	} Scanner in=new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in int []arr=new int[n]; arr new int[n] n int []dp= new int[n]; dp new int[n] n for(int i=0;i<n;i++)
			arr[i]=in.nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i arr[i]=in.nextInt(); arr[i]=in.nextInt() arr[i] arr i in.nextInt() in.nextInt in dp[0]=0 dp[0] dp 0 0 for(int i=1;i<n;i++) {
			if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		} int i=1; int i=1; i 1 i<n i n i++ i++ i {
			if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		} {
			if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		} if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]); i-2>=0 i-2 i 2 0 {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			} dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2])) dp[i] dp i Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2])) Math.min Math dp[i-1]+Math.abs(arr[i]-arr[i-1]) dp[i-1] dp i-1 i 1 Math.abs(arr[i]-arr[i-1]) Math.abs Math arr[i]-arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 dp[i-2]+Math.abs(arr[i]-arr[i-2]) dp[i-2] dp i-2 i 2 Math.abs(arr[i]-arr[i-2]) Math.abs Math arr[i]-arr[i-2] arr[i] arr i arr[i-2] arr i-2 i 2 dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]) dp[i] dp i dp[i-1]+Math.abs(arr[i]-arr[i-1]) dp[i-1] dp i-1 i 1 Math.abs(arr[i]-arr[i-1]) Math.abs Math arr[i]-arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 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 class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int []arr=new int[n];
		int []dp= new int[n];
		for(int i=0;i<n;i++)
			arr[i]=in.nextInt();
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		}
		System.out.println(dp[n-1]);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int []arr=new int[n];
		int []dp= new int[n];
		for(int i=0;i<n;i++)
			arr[i]=in.nextInt();
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		}
		System.out.println(dp[n-1]);
	}

} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int []arr=new int[n];
		int []dp= new int[n];
		for(int i=0;i<n;i++)
			arr[i]=in.nextInt();
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-2>=0) {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
			else
				dp[i]=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		}
		System.out.println(dp[n-1]);
	}

}
