import java.util.ArrayList;
import java.util.*;
  public class Main
{
	public static void main (String[] args)
	 {
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt();
		int h[]=new int[n];
		for(i=0;i<n;i++)
			h[i]=sc.nextInt();
		int dp[]=new int[n];
		//Arrays.fill(dp, );
		for(i=0;i<n;i++)
		{
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		}
		System.out.println(dp[n-1]);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.*; util.* java public class Main
{
	public static void main (String[] args)
	 {
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt();
		int h[]=new int[n];
		for(i=0;i<n;i++)
			h[i]=sc.nextInt();
		int dp[]=new int[n];
		//Arrays.fill(dp, );
		for(i=0;i<n;i++)
		{
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		}
		System.out.println(dp[n-1]);
	}
} Main public static void main (String[] args)
	 {
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt();
		int h[]=new int[n];
		for(i=0;i<n;i++)
			h[i]=sc.nextInt();
		int dp[]=new int[n];
		//Arrays.fill(dp, );
		for(i=0;i<n;i++)
		{
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		}
		System.out.println(dp[n-1]);
	} main {
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt();
		int h[]=new int[n];
		for(i=0;i<n;i++)
			h[i]=sc.nextInt();
		int dp[]=new int[n];
		//Arrays.fill(dp, );
		for(i=0;i<n;i++)
		{
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		}
		System.out.println(dp[n-1]);
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int i; i int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int h[]=new int[n]; h new int[n] n for(i=0;i<n;i++)
			h[i]=sc.nextInt(); i=0; i=0 i 0 i<n i n i++ i++ i h[i]=sc.nextInt(); h[i]=sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc int dp[]=new int[n]; dp new int[n] n for(i=0;i<n;i++)
		{
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		} i=0; i=0 i 0 i<n i n i++ i++ i {
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		} {
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		} if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]); i-1>=0&&i-2>=0 i-1>=0 i-1 i 1 0 i-2>=0 i-2 i 2 0 dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]) dp[i] dp i Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]) Math.min Math Math.abs(h[i-2]-h[i])+dp[i-2] Math.abs(h[i-2]-h[i]) Math.abs Math h[i-2]-h[i] h[i-2] h i-2 i 2 h[i] h i dp[i-2] dp i-2 i 2 Math.abs(h[i-1]-h[i])+dp[i-1] Math.abs(h[i-1]-h[i]) Math.abs Math h[i-1]-h[i] h[i-1] h i-1 i 1 h[i] h i dp[i-1] dp i-1 i 1 if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]); i-1>=0 i-1 i 1 0 dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]) dp[i] dp i Math.abs(h[i-1]-h[i]+dp[i-1]) Math.abs Math h[i-1]-h[i]+dp[i-1] h[i-1]-h[i] h[i-1] h i-1 i 1 h[i] h i dp[i-1] dp 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)
	 {
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt();
		int h[]=new int[n];
		for(i=0;i<n;i++)
			h[i]=sc.nextInt();
		int dp[]=new int[n];
		//Arrays.fill(dp, );
		for(i=0;i<n;i++)
		{
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		}
		System.out.println(dp[n-1]);
	}
} public class Main
{
	public static void main (String[] args)
	 {
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt();
		int h[]=new int[n];
		for(i=0;i<n;i++)
			h[i]=sc.nextInt();
		int dp[]=new int[n];
		//Arrays.fill(dp, );
		for(i=0;i<n;i++)
		{
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		}
		System.out.println(dp[n-1]);
	}
} Main
import java.util.ArrayList;
import java.util.*;
  public class Main
{
	public static void main (String[] args)
	 {
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt();
		int h[]=new int[n];
		for(i=0;i<n;i++)
			h[i]=sc.nextInt();
		int dp[]=new int[n];
		//Arrays.fill(dp, );
		for(i=0;i<n;i++)
		{
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		}
		System.out.println(dp[n-1]);
	}
}