import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) 
	{
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
	    int[]arr=new int[n];
	    for(int i=0;i<n;i++){
	        arr[i]=s.nextInt();
	    }
	    int dp[]=new int[n+1];
	    dp[0]=0;
	    dp[1]=0;
	    dp[2]=Math.abs(arr[1]-arr[0]);
	    for(int i=2;i<n;i++){
	        int op1=Math.abs(arr[i]-arr[i-2]);
	        int op2=Math.abs(arr[i]-arr[i-1]);
	        dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1);
	    }
	    System.out.println(dp[n]);
	    
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{
	public static void main (String[] args) 
	{
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
	    int[]arr=new int[n];
	    for(int i=0;i<n;i++){
	        arr[i]=s.nextInt();
	    }
	    int dp[]=new int[n+1];
	    dp[0]=0;
	    dp[1]=0;
	    dp[2]=Math.abs(arr[1]-arr[0]);
	    for(int i=2;i<n;i++){
	        int op1=Math.abs(arr[i]-arr[i-2]);
	        int op2=Math.abs(arr[i]-arr[i-1]);
	        dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1);
	    }
	    System.out.println(dp[n]);
	    
	}
} Main public static void main (String[] args) 
	{
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
	    int[]arr=new int[n];
	    for(int i=0;i<n;i++){
	        arr[i]=s.nextInt();
	    }
	    int dp[]=new int[n+1];
	    dp[0]=0;
	    dp[1]=0;
	    dp[2]=Math.abs(arr[1]-arr[0]);
	    for(int i=2;i<n;i++){
	        int op1=Math.abs(arr[i]-arr[i-2]);
	        int op2=Math.abs(arr[i]-arr[i-1]);
	        dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1);
	    }
	    System.out.println(dp[n]);
	    
	} main {
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
	    int[]arr=new int[n];
	    for(int i=0;i<n;i++){
	        arr[i]=s.nextInt();
	    }
	    int dp[]=new int[n+1];
	    dp[0]=0;
	    dp[1]=0;
	    dp[2]=Math.abs(arr[1]-arr[0]);
	    for(int i=2;i<n;i++){
	        int op1=Math.abs(arr[i]-arr[i-2]);
	        int op2=Math.abs(arr[i]-arr[i-1]);
	        dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1);
	    }
	    System.out.println(dp[n]);
	    
	} Scanner s=new Scanner(System.in); s new Scanner(System.in) int n=s.nextInt(); n s.nextInt() s.nextInt s int[]arr=new int[n]; arr new int[n] n for(int i=0;i<n;i++){
	        arr[i]=s.nextInt();
	    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
	        arr[i]=s.nextInt();
	    } {
	        arr[i]=s.nextInt();
	    } arr[i]=s.nextInt() arr[i] arr i s.nextInt() s.nextInt s int dp[]=new int[n+1]; dp new int[n+1] n+1 n 1 dp[0]=0 dp[0] dp 0 0 dp[1]=0 dp[1] dp 1 0 dp[2]=Math.abs(arr[1]-arr[0]) dp[2] dp 2 Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 for(int i=2;i<n;i++){
	        int op1=Math.abs(arr[i]-arr[i-2]);
	        int op2=Math.abs(arr[i]-arr[i-1]);
	        dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1);
	    } int i=2; int i=2; i 2 i<n i n i++ i++ i {
	        int op1=Math.abs(arr[i]-arr[i-2]);
	        int op2=Math.abs(arr[i]-arr[i-1]);
	        dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1);
	    } {
	        int op1=Math.abs(arr[i]-arr[i-2]);
	        int op2=Math.abs(arr[i]-arr[i-1]);
	        dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1);
	    } int op1=Math.abs(arr[i]-arr[i-2]); op1 Math.abs(arr[i]-arr[i-2]) Math.abs Math arr[i]-arr[i-2] arr[i] arr i arr[i-2] arr i-2 i 2 int op2=Math.abs(arr[i]-arr[i-1]); op2 Math.abs(arr[i]-arr[i-1]) Math.abs Math arr[i]-arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1) dp[i+1] dp i+1 i 1 Math.min(dp[i]+op2,dp[i-1]+op1) Math.min Math dp[i]+op2 dp[i] dp i op2 dp[i-1]+op1 dp[i-1] dp i-1 i 1 op1 System.out.println(dp[n]) System.out.println System.out System System.out dp[n] dp n String[] args args public class Main
{
	public static void main (String[] args) 
	{
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
	    int[]arr=new int[n];
	    for(int i=0;i<n;i++){
	        arr[i]=s.nextInt();
	    }
	    int dp[]=new int[n+1];
	    dp[0]=0;
	    dp[1]=0;
	    dp[2]=Math.abs(arr[1]-arr[0]);
	    for(int i=2;i<n;i++){
	        int op1=Math.abs(arr[i]-arr[i-2]);
	        int op2=Math.abs(arr[i]-arr[i-1]);
	        dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1);
	    }
	    System.out.println(dp[n]);
	    
	}
} public class Main
{
	public static void main (String[] args) 
	{
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
	    int[]arr=new int[n];
	    for(int i=0;i<n;i++){
	        arr[i]=s.nextInt();
	    }
	    int dp[]=new int[n+1];
	    dp[0]=0;
	    dp[1]=0;
	    dp[2]=Math.abs(arr[1]-arr[0]);
	    for(int i=2;i<n;i++){
	        int op1=Math.abs(arr[i]-arr[i-2]);
	        int op2=Math.abs(arr[i]-arr[i-1]);
	        dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1);
	    }
	    System.out.println(dp[n]);
	    
	}
} Main
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) 
	{
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
	    int[]arr=new int[n];
	    for(int i=0;i<n;i++){
	        arr[i]=s.nextInt();
	    }
	    int dp[]=new int[n+1];
	    dp[0]=0;
	    dp[1]=0;
	    dp[2]=Math.abs(arr[1]-arr[0]);
	    for(int i=2;i<n;i++){
	        int op1=Math.abs(arr[i]-arr[i-2]);
	        int op2=Math.abs(arr[i]-arr[i-1]);
	        dp[i+1]=Math.min(dp[i]+op2,dp[i-1]+op1);
	    }
	    System.out.println(dp[n]);
	    
	}
}