/**
 * 
 */
//package AtCoder;
import java.util.*;
/**
 * @author Shivansh Singh
 *
 */
public class Main {

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

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

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

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

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

} public class Main {

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

} Main
/**
 * 
 */
//package AtCoder;
import java.util.*;
/**
 * @author Shivansh Singh
 *
 */
public class Main {

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

}
