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();
		dp=new int[n];
		Arrays.fill(dp, -1);
		int ans=frog(ar,0,n);
		System.out.println(ans);
	}

	private static int frog(int[] ar, int i,int n) {
		// TODO Auto-generated method stub
		if(i>=n-1) {
			//System.out.println(1);
			return 0;

		}
		
		if(dp[i]!=-1)
			return dp[i];
		
		int op1=(i+1<n?Math.abs(ar[i]-ar[i+1])+frog(ar, i+1, n):Integer.MAX_VALUE);
		
		int op2=(i+2<n?Math.abs(ar[i]-ar[i+2])+frog(ar, i+2, n):Integer.MAX_VALUE);
		
		dp[i]= Math.min(op1, op2);
		
		return dp[i];
		
	}

} 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();
		dp=new int[n];
		Arrays.fill(dp, -1);
		int ans=frog(ar,0,n);
		System.out.println(ans);
	}

	private static int frog(int[] ar, int i,int n) {
		// TODO Auto-generated method stub
		if(i>=n-1) {
			//System.out.println(1);
			return 0;

		}
		
		if(dp[i]!=-1)
			return dp[i];
		
		int op1=(i+1<n?Math.abs(ar[i]-ar[i+1])+frog(ar, i+1, n):Integer.MAX_VALUE);
		
		int op2=(i+2<n?Math.abs(ar[i]-ar[i+2])+frog(ar, i+2, n):Integer.MAX_VALUE);
		
		dp[i]= Math.min(op1, op2);
		
		return dp[i];
		
	}

} 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();
		dp=new int[n];
		Arrays.fill(dp, -1);
		int ans=frog(ar,0,n);
		System.out.println(ans);
	} 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();
		dp=new int[n];
		Arrays.fill(dp, -1);
		int ans=frog(ar,0,n);
		System.out.println(ans);
	} 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 dp=new int[n] dp new int[n] n Arrays.fill(dp, -1) Arrays.fill Arrays dp -1 1 int ans=frog(ar,0,n); ans frog(ar,0,n) frog ar 0 n System.out.println(ans) System.out.println System.out System System.out ans String[] args args private static int frog(int[] ar, int i,int n) {
		// TODO Auto-generated method stub
		if(i>=n-1) {
			//System.out.println(1);
			return 0;

		}
		
		if(dp[i]!=-1)
			return dp[i];
		
		int op1=(i+1<n?Math.abs(ar[i]-ar[i+1])+frog(ar, i+1, n):Integer.MAX_VALUE);
		
		int op2=(i+2<n?Math.abs(ar[i]-ar[i+2])+frog(ar, i+2, n):Integer.MAX_VALUE);
		
		dp[i]= Math.min(op1, op2);
		
		return dp[i];
		
	} frog {
		// TODO Auto-generated method stub
		if(i>=n-1) {
			//System.out.println(1);
			return 0;

		}
		
		if(dp[i]!=-1)
			return dp[i];
		
		int op1=(i+1<n?Math.abs(ar[i]-ar[i+1])+frog(ar, i+1, n):Integer.MAX_VALUE);
		
		int op2=(i+2<n?Math.abs(ar[i]-ar[i+2])+frog(ar, i+2, n):Integer.MAX_VALUE);
		
		dp[i]= Math.min(op1, op2);
		
		return dp[i];
		
	} if(i>=n-1) {
			//System.out.println(1);
			return 0;

		} i>=n-1 i n-1 n 1 {
			//System.out.println(1);
			return 0;

		} return 0; 0 if(dp[i]!=-1)
			return dp[i]; dp[i]!=-1 dp[i] dp i -1 1 return dp[i]; dp[i] dp i int op1=(i+1<n?Math.abs(ar[i]-ar[i+1])+frog(ar, i+1, n):Integer.MAX_VALUE); op1 (i+1<n?Math.abs(ar[i]-ar[i+1])+frog(ar, i+1, n):Integer.MAX_VALUE) i+1<n i+1 i 1 n Math.abs(ar[i]-ar[i+1])+frog(ar, i+1, n) 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 frog(ar, i+1, n) frog ar i+1 i 1 n Integer.MAX_VALUE Integer Integer.MAX_VALUE int op2=(i+2<n?Math.abs(ar[i]-ar[i+2])+frog(ar, i+2, n):Integer.MAX_VALUE); op2 (i+2<n?Math.abs(ar[i]-ar[i+2])+frog(ar, i+2, n):Integer.MAX_VALUE) i+2<n i+2 i 2 n Math.abs(ar[i]-ar[i+2])+frog(ar, i+2, n) 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 frog(ar, i+2, n) frog ar i+2 i 2 n Integer.MAX_VALUE Integer Integer.MAX_VALUE dp[i]= Math.min(op1, op2) dp[i] dp i Math.min(op1, op2) Math.min Math op1 op2 return dp[i]; dp[i] dp i int[] ar ar int i i int n n 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();
		dp=new int[n];
		Arrays.fill(dp, -1);
		int ans=frog(ar,0,n);
		System.out.println(ans);
	}

	private static int frog(int[] ar, int i,int n) {
		// TODO Auto-generated method stub
		if(i>=n-1) {
			//System.out.println(1);
			return 0;

		}
		
		if(dp[i]!=-1)
			return dp[i];
		
		int op1=(i+1<n?Math.abs(ar[i]-ar[i+1])+frog(ar, i+1, n):Integer.MAX_VALUE);
		
		int op2=(i+2<n?Math.abs(ar[i]-ar[i+2])+frog(ar, i+2, n):Integer.MAX_VALUE);
		
		dp[i]= Math.min(op1, op2);
		
		return dp[i];
		
	}

} 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();
		dp=new int[n];
		Arrays.fill(dp, -1);
		int ans=frog(ar,0,n);
		System.out.println(ans);
	}

	private static int frog(int[] ar, int i,int n) {
		// TODO Auto-generated method stub
		if(i>=n-1) {
			//System.out.println(1);
			return 0;

		}
		
		if(dp[i]!=-1)
			return dp[i];
		
		int op1=(i+1<n?Math.abs(ar[i]-ar[i+1])+frog(ar, i+1, n):Integer.MAX_VALUE);
		
		int op2=(i+2<n?Math.abs(ar[i]-ar[i+2])+frog(ar, i+2, n):Integer.MAX_VALUE);
		
		dp[i]= Math.min(op1, op2);
		
		return dp[i];
		
	}

} 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();
		dp=new int[n];
		Arrays.fill(dp, -1);
		int ans=frog(ar,0,n);
		System.out.println(ans);
	}

	private static int frog(int[] ar, int i,int n) {
		// TODO Auto-generated method stub
		if(i>=n-1) {
			//System.out.println(1);
			return 0;

		}
		
		if(dp[i]!=-1)
			return dp[i];
		
		int op1=(i+1<n?Math.abs(ar[i]-ar[i+1])+frog(ar, i+1, n):Integer.MAX_VALUE);
		
		int op2=(i+2<n?Math.abs(ar[i]-ar[i+2])+frog(ar, i+2, n):Integer.MAX_VALUE);
		
		dp[i]= Math.min(op1, op2);
		
		return dp[i];
		
	}

}
