import java.util.*;
import java.io.*;
class Main {
  

    public static long frog(long[] arr){
        long[] dp = new long[arr.length];
      
        for(int i = 1; i < arr.length; i++){
            long option1 = Long.MAX_VALUE;
            long option2 = Long.MAX_VALUE;
            option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
            if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            }

            dp[i] = Math.min(option1,option2);
        
        }

        return (dp[dp.length-1]);
    }
    
    public static void main(String[] args) throws Exception{
        StringTokenizer str;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        long[] arr = new long[n];
        int i = 0;
           str = new StringTokenizer(br.readLine().trim()," ");   
            while(str.hasMoreTokens()){
                arr[i]=Long.parseLong(str.nextToken());
                i++;
            }
       
         System.out.println(frog(arr));
     
    }
} import java.util.*; util.* java import java.io.*; io.* java class Main {
  

    public static long frog(long[] arr){
        long[] dp = new long[arr.length];
      
        for(int i = 1; i < arr.length; i++){
            long option1 = Long.MAX_VALUE;
            long option2 = Long.MAX_VALUE;
            option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
            if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            }

            dp[i] = Math.min(option1,option2);
        
        }

        return (dp[dp.length-1]);
    }
    
    public static void main(String[] args) throws Exception{
        StringTokenizer str;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        long[] arr = new long[n];
        int i = 0;
           str = new StringTokenizer(br.readLine().trim()," ");   
            while(str.hasMoreTokens()){
                arr[i]=Long.parseLong(str.nextToken());
                i++;
            }
       
         System.out.println(frog(arr));
     
    }
} Main public static long frog(long[] arr){
        long[] dp = new long[arr.length];
      
        for(int i = 1; i < arr.length; i++){
            long option1 = Long.MAX_VALUE;
            long option2 = Long.MAX_VALUE;
            option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
            if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            }

            dp[i] = Math.min(option1,option2);
        
        }

        return (dp[dp.length-1]);
    } frog {
        long[] dp = new long[arr.length];
      
        for(int i = 1; i < arr.length; i++){
            long option1 = Long.MAX_VALUE;
            long option2 = Long.MAX_VALUE;
            option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
            if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            }

            dp[i] = Math.min(option1,option2);
        
        }

        return (dp[dp.length-1]);
    } long[] dp = new long[arr.length]; dp new long[arr.length] arr.length arr arr.length for(int i = 1; i < arr.length; i++){
            long option1 = Long.MAX_VALUE;
            long option2 = Long.MAX_VALUE;
            option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
            if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            }

            dp[i] = Math.min(option1,option2);
        
        } int i = 1; int i = 1; i 1 i < arr.length i arr.length arr arr.length i++ i++ i {
            long option1 = Long.MAX_VALUE;
            long option2 = Long.MAX_VALUE;
            option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
            if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            }

            dp[i] = Math.min(option1,option2);
        
        } {
            long option1 = Long.MAX_VALUE;
            long option2 = Long.MAX_VALUE;
            option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
            if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            }

            dp[i] = Math.min(option1,option2);
        
        } long option1 = Long.MAX_VALUE; option1 Long.MAX_VALUE Long Long.MAX_VALUE long option2 = Long.MAX_VALUE; option2 Long.MAX_VALUE Long Long.MAX_VALUE option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]) option1 dp[i-1] + Math.abs(arr[i] - arr[i-1]) dp[i-1] dp i-1 i 1 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 if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            } i-2 >= 0 i-2 i 2 0 {
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            } option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]) option2 dp[i-2] + Math.abs(arr[i] - arr[i-2]) dp[i-2] dp i-2 i 2 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 dp[i] = Math.min(option1,option2) dp[i] dp i Math.min(option1,option2) Math.min Math option1 option2 return (dp[dp.length-1]); (dp[dp.length-1]) dp dp.length-1 dp.length dp dp.length 1 long[] arr arr public static void main(String[] args) throws Exception{
        StringTokenizer str;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        long[] arr = new long[n];
        int i = 0;
           str = new StringTokenizer(br.readLine().trim()," ");   
            while(str.hasMoreTokens()){
                arr[i]=Long.parseLong(str.nextToken());
                i++;
            }
       
         System.out.println(frog(arr));
     
    } main {
        StringTokenizer str;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        long[] arr = new long[n];
        int i = 0;
           str = new StringTokenizer(br.readLine().trim()," ");   
            while(str.hasMoreTokens()){
                arr[i]=Long.parseLong(str.nextToken());
                i++;
            }
       
         System.out.println(frog(arr));
     
    } StringTokenizer str; str BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(br.readLine().trim()); n Integer.parseInt(br.readLine().trim()) Integer.parseInt Integer br.readLine().trim() br.readLine().trim br.readLine() br.readLine br long[] arr = new long[n]; arr new long[n] n int i = 0; i 0 str = new StringTokenizer(br.readLine().trim()," ") str new StringTokenizer(br.readLine().trim()," ") while(str.hasMoreTokens()){
                arr[i]=Long.parseLong(str.nextToken());
                i++;
            } str.hasMoreTokens() str.hasMoreTokens str {
                arr[i]=Long.parseLong(str.nextToken());
                i++;
            } arr[i]=Long.parseLong(str.nextToken()) arr[i] arr i Long.parseLong(str.nextToken()) Long.parseLong Long str.nextToken() str.nextToken str i++ i System.out.println(frog(arr)) System.out.println System.out System System.out frog(arr) frog arr String[] args args
import java.util.*;
import java.io.*;
class Main {
  

    public static long frog(long[] arr){
        long[] dp = new long[arr.length];
      
        for(int i = 1; i < arr.length; i++){
            long option1 = Long.MAX_VALUE;
            long option2 = Long.MAX_VALUE;
            option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
            if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            }

            dp[i] = Math.min(option1,option2);
        
        }

        return (dp[dp.length-1]);
    }
    
    public static void main(String[] args) throws Exception{
        StringTokenizer str;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        long[] arr = new long[n];
        int i = 0;
           str = new StringTokenizer(br.readLine().trim()," ");   
            while(str.hasMoreTokens()){
                arr[i]=Long.parseLong(str.nextToken());
                i++;
            }
       
         System.out.println(frog(arr));
     
    }
}