import java.util.*;


import java.io.*;
import java.math.BigInteger;


public class Main 
{   
	static int dp[];
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int ar[]=new int[n];
		
		for(int i=0;i<n;i++)
			ar[i]=s.nextInt();
		
		
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(ar[1]-ar[0]);
		for(int i=2;i<n;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		}
		System.out.println(dp[n-1]);
    }
} import java.util.*; util.* java import java.io.*; io.* java import java.math.BigInteger; BigInteger java.math public class Main 
{   
	static int dp[];
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int ar[]=new int[n];
		
		for(int i=0;i<n;i++)
			ar[i]=s.nextInt();
		
		
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(ar[1]-ar[0]);
		for(int i=2;i<n;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		}
		System.out.println(dp[n-1]);
    }
} Main static int dp[]; dp public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int ar[]=new int[n];
		
		for(int i=0;i<n;i++)
			ar[i]=s.nextInt();
		
		
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(ar[1]-ar[0]);
		for(int i=2;i<n;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		}
		System.out.println(dp[n-1]);
    } main { 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int ar[]=new int[n];
		
		for(int i=0;i<n;i++)
			ar[i]=s.nextInt();
		
		
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(ar[1]-ar[0]);
		for(int i=2;i<n;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		}
		System.out.println(dp[n-1]);
    } Scanner s=new Scanner(System.in); s new Scanner(System.in) int n=s.nextInt(); n s.nextInt() s.nextInt s int ar[]=new int[n]; ar new int[n] n for(int i=0;i<n;i++)
			ar[i]=s.nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i ar[i]=s.nextInt(); ar[i]=s.nextInt() ar[i] ar i s.nextInt() s.nextInt s int dp[]=new int[n]; dp new int[n] n dp[0]=0 dp[0] dp 0 0 dp[1]=Math.abs(ar[1]-ar[0]) dp[1] dp 1 Math.abs(ar[1]-ar[0]) Math.abs Math ar[1]-ar[0] ar[1] ar 1 ar[0] ar 0 for(int i=2;i<n;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		} int i=2; int i=2; i 2 i<n i n i++ i++ i {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		} {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		} dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2])) dp[i] dp i Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2])) Math.min Math dp[i-1]+Math.abs(ar[i]-ar[i-1]) dp[i-1] dp i-1 i 1 Math.abs(ar[i]-ar[i-1]) Math.abs Math ar[i]-ar[i-1] ar[i] ar i ar[i-1] ar i-1 i 1 dp[i-2]+Math.abs(ar[i]-ar[i-2]) dp[i-2] dp i-2 i 2 Math.abs(ar[i]-ar[i-2]) Math.abs Math ar[i]-ar[i-2] ar[i] ar i ar[i-2] ar i-2 i 2 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 
{   
	static int dp[];
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int ar[]=new int[n];
		
		for(int i=0;i<n;i++)
			ar[i]=s.nextInt();
		
		
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(ar[1]-ar[0]);
		for(int i=2;i<n;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		}
		System.out.println(dp[n-1]);
    }
} public class Main 
{   
	static int dp[];
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int ar[]=new int[n];
		
		for(int i=0;i<n;i++)
			ar[i]=s.nextInt();
		
		
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(ar[1]-ar[0]);
		for(int i=2;i<n;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		}
		System.out.println(dp[n-1]);
    }
} Main
import java.util.*;


import java.io.*;
import java.math.BigInteger;


public class Main 
{   
	static int dp[];
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int ar[]=new int[n];
		
		for(int i=0;i<n;i++)
			ar[i]=s.nextInt();
		
		
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(ar[1]-ar[0]);
		for(int i=2;i<n;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		}
		System.out.println(dp[n-1]);
    }
}