import java.util.*; 
  
public class Main{

    public static int n;

    public static int [] arr = new int[100000];

    public static int [] darr = new int[100000];

    public static int minCostJump(int i){

        if(darr[i] != -1) return darr[i];

        if(i == n-1) return 0;

        if(i > n) return Integer.MAX_VALUE;
        
        if(i+2 < n)
        return darr[i] = Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2]));

        return darr[i] = minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]);
    } 

    public static void main(String args[]) 
    { 
        Scanner in = new Scanner(System.in); 
  
        n = in.nextInt();

        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
            darr[i] = -1;
        }

        int jumps = minCostJump(0);

        System.out.println(jumps);
    }

}  import java.util.*; util.* java public class Main{

    public static int n;

    public static int [] arr = new int[100000];

    public static int [] darr = new int[100000];

    public static int minCostJump(int i){

        if(darr[i] != -1) return darr[i];

        if(i == n-1) return 0;

        if(i > n) return Integer.MAX_VALUE;
        
        if(i+2 < n)
        return darr[i] = Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2]));

        return darr[i] = minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]);
    } 

    public static void main(String args[]) 
    { 
        Scanner in = new Scanner(System.in); 
  
        n = in.nextInt();

        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
            darr[i] = -1;
        }

        int jumps = minCostJump(0);

        System.out.println(jumps);
    }

} Main public static int n; n public static int [] arr = new int[100000]; arr new int[100000] 100000 public static int [] darr = new int[100000]; darr new int[100000] 100000 public static int minCostJump(int i){

        if(darr[i] != -1) return darr[i];

        if(i == n-1) return 0;

        if(i > n) return Integer.MAX_VALUE;
        
        if(i+2 < n)
        return darr[i] = Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2]));

        return darr[i] = minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]);
    } minCostJump {

        if(darr[i] != -1) return darr[i];

        if(i == n-1) return 0;

        if(i > n) return Integer.MAX_VALUE;
        
        if(i+2 < n)
        return darr[i] = Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2]));

        return darr[i] = minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]);
    } if(darr[i] != -1) return darr[i]; darr[i] != -1 darr[i] darr i -1 1 return darr[i]; darr[i] darr i if(i == n-1) return 0; i == n-1 i n-1 n 1 return 0; 0 if(i > n) return Integer.MAX_VALUE; i > n i n return Integer.MAX_VALUE; Integer.MAX_VALUE Integer Integer.MAX_VALUE if(i+2 < n)
        return darr[i] = Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2])); i+2 < n i+2 i 2 n return darr[i] = Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2])); darr[i] = Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2])) darr[i] darr i Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2])) Math.min Math minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]) minCostJump(i + 1) minCostJump 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 minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2]) minCostJump(i + 2) minCostJump 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 return darr[i] = minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]); darr[i] = minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]) darr[i] darr i minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]) minCostJump(i + 1) minCostJump 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 int i i public static void main(String args[]) 
    { 
        Scanner in = new Scanner(System.in); 
  
        n = in.nextInt();

        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
            darr[i] = -1;
        }

        int jumps = minCostJump(0);

        System.out.println(jumps);
    } main { 
        Scanner in = new Scanner(System.in); 
  
        n = in.nextInt();

        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
            darr[i] = -1;
        }

        int jumps = minCostJump(0);

        System.out.println(jumps);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) n = in.nextInt() n in.nextInt() in.nextInt in for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
            darr[i] = -1;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            arr[i] = in.nextInt();
            darr[i] = -1;
        } {
            arr[i] = in.nextInt();
            darr[i] = -1;
        } arr[i] = in.nextInt() arr[i] arr i in.nextInt() in.nextInt in darr[i] = -1 darr[i] darr i -1 1 int jumps = minCostJump(0); jumps minCostJump(0) minCostJump 0 System.out.println(jumps) System.out.println System.out System System.out jumps String args[] args public class Main{

    public static int n;

    public static int [] arr = new int[100000];

    public static int [] darr = new int[100000];

    public static int minCostJump(int i){

        if(darr[i] != -1) return darr[i];

        if(i == n-1) return 0;

        if(i > n) return Integer.MAX_VALUE;
        
        if(i+2 < n)
        return darr[i] = Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2]));

        return darr[i] = minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]);
    } 

    public static void main(String args[]) 
    { 
        Scanner in = new Scanner(System.in); 
  
        n = in.nextInt();

        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
            darr[i] = -1;
        }

        int jumps = minCostJump(0);

        System.out.println(jumps);
    }

} public class Main{

    public static int n;

    public static int [] arr = new int[100000];

    public static int [] darr = new int[100000];

    public static int minCostJump(int i){

        if(darr[i] != -1) return darr[i];

        if(i == n-1) return 0;

        if(i > n) return Integer.MAX_VALUE;
        
        if(i+2 < n)
        return darr[i] = Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2]));

        return darr[i] = minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]);
    } 

    public static void main(String args[]) 
    { 
        Scanner in = new Scanner(System.in); 
  
        n = in.nextInt();

        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
            darr[i] = -1;
        }

        int jumps = minCostJump(0);

        System.out.println(jumps);
    }

} Main
import java.util.*; 
  
public class Main{

    public static int n;

    public static int [] arr = new int[100000];

    public static int [] darr = new int[100000];

    public static int minCostJump(int i){

        if(darr[i] != -1) return darr[i];

        if(i == n-1) return 0;

        if(i > n) return Integer.MAX_VALUE;
        
        if(i+2 < n)
        return darr[i] = Math.min(minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]), minCostJump(i + 2) + Math.abs(arr[i] - arr[i+2]));

        return darr[i] = minCostJump(i + 1) + Math.abs(arr[i] - arr[i+1]);
    } 

    public static void main(String args[]) 
    { 
        Scanner in = new Scanner(System.in); 
  
        n = in.nextInt();

        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
            darr[i] = -1;
        }

        int jumps = minCostJump(0);

        System.out.println(jumps);
    }

} 