import java.io.*;
import java.util.*;

public class Main{ 
   static class Fast{
     public BufferedReader br;
     public StringTokenizer st;
     
     public Fast(){
          br =new BufferedReader(new InputStreamReader(System.in));
     }
     
     String next(){
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          }
     int nextInt(){
          return Integer.parseInt(next());
     }

     long nextLong(){
          return Long.parseLong(next());
     }

 }
  
	public static void main(String[] args)throws Exception{
         //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
          Fast f=new Fast();
         PrintWriter out = new PrintWriter(System.out);
        // StringBuilder str=new StringBuilder();
         //  int x=Integer.parseInt(st.nextToken());
         
        //st=new StringTokenizer(br.readLine()); 

        
        int n=f.nextInt();
        int h[]=new int[n+1];
        for (int i=0;i<n;i++ ) {
          h[i+1]=f.nextInt();
        }

        int dp[]=new int[n+1];
        dp[0]=0;dp[1]=0;dp[2]=Math.abs(h[2]-h[1]);
        int way1=0,way2=0;
        for (int i=3;i<dp.length;i++) {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        }

        out.println(dp[n]);
    out.close();

}
}

 import java.io.*; io.* java import java.util.*; util.* java public class Main{ 
   static class Fast{
     public BufferedReader br;
     public StringTokenizer st;
     
     public Fast(){
          br =new BufferedReader(new InputStreamReader(System.in));
     }
     
     String next(){
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          }
     int nextInt(){
          return Integer.parseInt(next());
     }

     long nextLong(){
          return Long.parseLong(next());
     }

 }
  
	public static void main(String[] args)throws Exception{
         //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
          Fast f=new Fast();
         PrintWriter out = new PrintWriter(System.out);
        // StringBuilder str=new StringBuilder();
         //  int x=Integer.parseInt(st.nextToken());
         
        //st=new StringTokenizer(br.readLine()); 

        
        int n=f.nextInt();
        int h[]=new int[n+1];
        for (int i=0;i<n;i++ ) {
          h[i+1]=f.nextInt();
        }

        int dp[]=new int[n+1];
        dp[0]=0;dp[1]=0;dp[2]=Math.abs(h[2]-h[1]);
        int way1=0,way2=0;
        for (int i=3;i<dp.length;i++) {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        }

        out.println(dp[n]);
    out.close();

}
} Main public static void main(String[] args)throws Exception{
         //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
          Fast f=new Fast();
         PrintWriter out = new PrintWriter(System.out);
        // StringBuilder str=new StringBuilder();
         //  int x=Integer.parseInt(st.nextToken());
         
        //st=new StringTokenizer(br.readLine()); 

        
        int n=f.nextInt();
        int h[]=new int[n+1];
        for (int i=0;i<n;i++ ) {
          h[i+1]=f.nextInt();
        }

        int dp[]=new int[n+1];
        dp[0]=0;dp[1]=0;dp[2]=Math.abs(h[2]-h[1]);
        int way1=0,way2=0;
        for (int i=3;i<dp.length;i++) {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        }

        out.println(dp[n]);
    out.close();

} main {
         //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
          Fast f=new Fast();
         PrintWriter out = new PrintWriter(System.out);
        // StringBuilder str=new StringBuilder();
         //  int x=Integer.parseInt(st.nextToken());
         
        //st=new StringTokenizer(br.readLine()); 

        
        int n=f.nextInt();
        int h[]=new int[n+1];
        for (int i=0;i<n;i++ ) {
          h[i+1]=f.nextInt();
        }

        int dp[]=new int[n+1];
        dp[0]=0;dp[1]=0;dp[2]=Math.abs(h[2]-h[1]);
        int way1=0,way2=0;
        for (int i=3;i<dp.length;i++) {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        }

        out.println(dp[n]);
    out.close();

} Fast f=new Fast(); f new Fast() PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n=f.nextInt(); n f.nextInt() f.nextInt f int h[]=new int[n+1]; h new int[n+1] n+1 n 1 for (int i=0;i<n;i++ ) {
          h[i+1]=f.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
          h[i+1]=f.nextInt();
        } {
          h[i+1]=f.nextInt();
        } h[i+1]=f.nextInt() h[i+1] h i+1 i 1 f.nextInt() f.nextInt f 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(h[2]-h[1]) dp[2] dp 2 Math.abs(h[2]-h[1]) Math.abs Math h[2]-h[1] h[2] h 2 h[1] h 1 int way1=0 way1 0 way2=0; way2 0 for (int i=3;i<dp.length;i++) {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        } int i=3; int i=3; i 3 i<dp.length i dp.length dp dp.length i++ i++ i {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        } {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        } way1=dp[i-1]+Math.abs(h[i]-h[i-1]) way1 dp[i-1]+Math.abs(h[i]-h[i-1]) dp[i-1] dp i-1 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 way2=dp[i-2]+Math.abs(h[i]-h[i-2]) way2 dp[i-2]+Math.abs(h[i]-h[i-2]) dp[i-2] dp i-2 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]=Math.min(way1,way2) dp[i] dp i Math.min(way1,way2) Math.min Math way1 way2 out.println(dp[n]) out.println out dp[n] dp n out.close() out.close out String[] args args static class Fast{
     public BufferedReader br;
     public StringTokenizer st;
     
     public Fast(){
          br =new BufferedReader(new InputStreamReader(System.in));
     }
     
     String next(){
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          }
     int nextInt(){
          return Integer.parseInt(next());
     }

     long nextLong(){
          return Long.parseLong(next());
     }

 } Fast public BufferedReader br; br public StringTokenizer st; st public Fast(){
          br =new BufferedReader(new InputStreamReader(System.in));
     } Fast {
          br =new BufferedReader(new InputStreamReader(System.in));
     } br =new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next(){
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          } next {
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          } while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          } st==null || !st.hasMoreTokens() st==null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          } try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               } catch(IOException e){
                    throw new RuntimeException(e);
               } IOException e {
                    throw new RuntimeException(e);
               } throw new RuntimeException(e); new RuntimeException(e) {
                    st=new StringTokenizer(br.readLine());
               } st=new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt(){
          return Integer.parseInt(next());
     } nextInt {
          return Integer.parseInt(next());
     } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong(){
          return Long.parseLong(next());
     } nextLong {
          return Long.parseLong(next());
     } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public class Main{ 
   static class Fast{
     public BufferedReader br;
     public StringTokenizer st;
     
     public Fast(){
          br =new BufferedReader(new InputStreamReader(System.in));
     }
     
     String next(){
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          }
     int nextInt(){
          return Integer.parseInt(next());
     }

     long nextLong(){
          return Long.parseLong(next());
     }

 }
  
	public static void main(String[] args)throws Exception{
         //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
          Fast f=new Fast();
         PrintWriter out = new PrintWriter(System.out);
        // StringBuilder str=new StringBuilder();
         //  int x=Integer.parseInt(st.nextToken());
         
        //st=new StringTokenizer(br.readLine()); 

        
        int n=f.nextInt();
        int h[]=new int[n+1];
        for (int i=0;i<n;i++ ) {
          h[i+1]=f.nextInt();
        }

        int dp[]=new int[n+1];
        dp[0]=0;dp[1]=0;dp[2]=Math.abs(h[2]-h[1]);
        int way1=0,way2=0;
        for (int i=3;i<dp.length;i++) {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        }

        out.println(dp[n]);
    out.close();

}
} public class Main{ 
   static class Fast{
     public BufferedReader br;
     public StringTokenizer st;
     
     public Fast(){
          br =new BufferedReader(new InputStreamReader(System.in));
     }
     
     String next(){
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          }
     int nextInt(){
          return Integer.parseInt(next());
     }

     long nextLong(){
          return Long.parseLong(next());
     }

 }
  
	public static void main(String[] args)throws Exception{
         //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
          Fast f=new Fast();
         PrintWriter out = new PrintWriter(System.out);
        // StringBuilder str=new StringBuilder();
         //  int x=Integer.parseInt(st.nextToken());
         
        //st=new StringTokenizer(br.readLine()); 

        
        int n=f.nextInt();
        int h[]=new int[n+1];
        for (int i=0;i<n;i++ ) {
          h[i+1]=f.nextInt();
        }

        int dp[]=new int[n+1];
        dp[0]=0;dp[1]=0;dp[2]=Math.abs(h[2]-h[1]);
        int way1=0,way2=0;
        for (int i=3;i<dp.length;i++) {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        }

        out.println(dp[n]);
    out.close();

}
} Main
import java.io.*;
import java.util.*;

public class Main{ 
   static class Fast{
     public BufferedReader br;
     public StringTokenizer st;
     
     public Fast(){
          br =new BufferedReader(new InputStreamReader(System.in));
     }
     
     String next(){
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          }
     int nextInt(){
          return Integer.parseInt(next());
     }

     long nextLong(){
          return Long.parseLong(next());
     }

 }
  
	public static void main(String[] args)throws Exception{
         //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
          Fast f=new Fast();
         PrintWriter out = new PrintWriter(System.out);
        // StringBuilder str=new StringBuilder();
         //  int x=Integer.parseInt(st.nextToken());
         
        //st=new StringTokenizer(br.readLine()); 

        
        int n=f.nextInt();
        int h[]=new int[n+1];
        for (int i=0;i<n;i++ ) {
          h[i+1]=f.nextInt();
        }

        int dp[]=new int[n+1];
        dp[0]=0;dp[1]=0;dp[2]=Math.abs(h[2]-h[1]);
        int way1=0,way2=0;
        for (int i=3;i<dp.length;i++) {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        }

        out.println(dp[n]);
    out.close();

}
}


