import java.util.*;
import java.lang.*;

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

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