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