import java.util.*;
public class Main{
    public static void main(String args[]) {
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    
    for(int i =0; i<n;i++)
    arr[i] = sc.nextInt();
   
      System.out.println(dpc(arr,n));
      
      
    }
    
    static int min(int[] arr, int n)
    { 
        if(n==1) return 0;
        if(n==2) return Math.abs(arr[n-1]-arr[n-2]);
            int op1 = Math.abs(arr[n-1]-arr[n-2]) +min(arr,n-1);
            int op2 = Math.abs(arr[n-1]-arr[n-3]) +min(arr,n-2);
          int res = Math.min(op1, op2);
          
          return res;
    }
    
    static int dpc(int[] a, int n)
    {
        int[] dp = new int[n];
        
    dp[0]=0;
    dp[1]=Math.abs(a[0]-a[1]);
    for(int i =2;i<n;i++)
    {
             dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);

    }
        
        return dp[n-1];
    }
    
} import java.util.*; util.* java public class Main{
    public static void main(String args[]) {
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    
    for(int i =0; i<n;i++)
    arr[i] = sc.nextInt();
   
      System.out.println(dpc(arr,n));
      
      
    }
    
    static int min(int[] arr, int n)
    { 
        if(n==1) return 0;
        if(n==2) return Math.abs(arr[n-1]-arr[n-2]);
            int op1 = Math.abs(arr[n-1]-arr[n-2]) +min(arr,n-1);
            int op2 = Math.abs(arr[n-1]-arr[n-3]) +min(arr,n-2);
          int res = Math.min(op1, op2);
          
          return res;
    }
    
    static int dpc(int[] a, int n)
    {
        int[] dp = new int[n];
        
    dp[0]=0;
    dp[1]=Math.abs(a[0]-a[1]);
    for(int i =2;i<n;i++)
    {
             dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);

    }
        
        return dp[n-1];
    }
    
} Main public static void main(String args[]) {
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    
    for(int i =0; i<n;i++)
    arr[i] = sc.nextInt();
   
      System.out.println(dpc(arr,n));
      
      
    } main {
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    
    for(int i =0; i<n;i++)
    arr[i] = sc.nextInt();
   
      System.out.println(dpc(arr,n));
      
      
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] arr = new int[n]; arr new int[n] n for(int i =0; i<n;i++)
    arr[i] = sc.nextInt(); int i =0; int i =0; i 0 i<n i n i++ i++ i arr[i] = sc.nextInt(); arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc System.out.println(dpc(arr,n)) System.out.println System.out System System.out dpc(arr,n) dpc arr n String args[] args static int min(int[] arr, int n)
    { 
        if(n==1) return 0;
        if(n==2) return Math.abs(arr[n-1]-arr[n-2]);
            int op1 = Math.abs(arr[n-1]-arr[n-2]) +min(arr,n-1);
            int op2 = Math.abs(arr[n-1]-arr[n-3]) +min(arr,n-2);
          int res = Math.min(op1, op2);
          
          return res;
    } min { 
        if(n==1) return 0;
        if(n==2) return Math.abs(arr[n-1]-arr[n-2]);
            int op1 = Math.abs(arr[n-1]-arr[n-2]) +min(arr,n-1);
            int op2 = Math.abs(arr[n-1]-arr[n-3]) +min(arr,n-2);
          int res = Math.min(op1, op2);
          
          return res;
    } if(n==1) return 0; n==1 n 1 return 0; 0 if(n==2) return Math.abs(arr[n-1]-arr[n-2]); n==2 n 2 return Math.abs(arr[n-1]-arr[n-2]); Math.abs(arr[n-1]-arr[n-2]) Math.abs Math arr[n-1]-arr[n-2] arr[n-1] arr n-1 n 1 arr[n-2] arr n-2 n 2 int op1 = Math.abs(arr[n-1]-arr[n-2]) +min(arr,n-1); op1 Math.abs(arr[n-1]-arr[n-2]) +min(arr,n-1) Math.abs(arr[n-1]-arr[n-2]) Math.abs Math arr[n-1]-arr[n-2] arr[n-1] arr n-1 n 1 arr[n-2] arr n-2 n 2 min(arr,n-1) min arr n-1 n 1 int op2 = Math.abs(arr[n-1]-arr[n-3]) +min(arr,n-2); op2 Math.abs(arr[n-1]-arr[n-3]) +min(arr,n-2) Math.abs(arr[n-1]-arr[n-3]) Math.abs Math arr[n-1]-arr[n-3] arr[n-1] arr n-1 n 1 arr[n-3] arr n-3 n 3 min(arr,n-2) min arr n-2 n 2 int res = Math.min(op1, op2); res Math.min(op1, op2) Math.min Math op1 op2 return res; res int[] arr arr int n n static int dpc(int[] a, int n)
    {
        int[] dp = new int[n];
        
    dp[0]=0;
    dp[1]=Math.abs(a[0]-a[1]);
    for(int i =2;i<n;i++)
    {
             dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);

    }
        
        return dp[n-1];
    } dpc {
        int[] dp = new int[n];
        
    dp[0]=0;
    dp[1]=Math.abs(a[0]-a[1]);
    for(int i =2;i<n;i++)
    {
             dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);

    }
        
        return dp[n-1];
    } int[] dp = new int[n]; dp new int[n] n dp[0]=0 dp[0] dp 0 0 dp[1]=Math.abs(a[0]-a[1]) dp[1] dp 1 Math.abs(a[0]-a[1]) Math.abs Math a[0]-a[1] a[0] a 0 a[1] a 1 for(int i =2;i<n;i++)
    {
             dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[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(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);

    } {
             dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);

    } dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]) dp[i] dp i Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]) Math.min Math Math.abs(a[i] - a[i - 1]) + dp[i - 1] Math.abs(a[i] - a[i - 1]) Math.abs Math a[i] - a[i - 1] a[i] a i a[i - 1] a i - 1 i 1 dp[i - 1] dp i - 1 i 1 Math.abs(a[i] - a[i - 2]) + dp[i - 2] Math.abs(a[i] - a[i - 2]) Math.abs Math a[i] - a[i - 2] a[i] a i a[i - 2] a i - 2 i 2 dp[i - 2] dp i - 2 i 2 return dp[n-1]; dp[n-1] dp n-1 n 1 int[] a a int n n public class Main{
    public static void main(String args[]) {
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    
    for(int i =0; i<n;i++)
    arr[i] = sc.nextInt();
   
      System.out.println(dpc(arr,n));
      
      
    }
    
    static int min(int[] arr, int n)
    { 
        if(n==1) return 0;
        if(n==2) return Math.abs(arr[n-1]-arr[n-2]);
            int op1 = Math.abs(arr[n-1]-arr[n-2]) +min(arr,n-1);
            int op2 = Math.abs(arr[n-1]-arr[n-3]) +min(arr,n-2);
          int res = Math.min(op1, op2);
          
          return res;
    }
    
    static int dpc(int[] a, int n)
    {
        int[] dp = new int[n];
        
    dp[0]=0;
    dp[1]=Math.abs(a[0]-a[1]);
    for(int i =2;i<n;i++)
    {
             dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);

    }
        
        return dp[n-1];
    }
    
} public class Main{
    public static void main(String args[]) {
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    
    for(int i =0; i<n;i++)
    arr[i] = sc.nextInt();
   
      System.out.println(dpc(arr,n));
      
      
    }
    
    static int min(int[] arr, int n)
    { 
        if(n==1) return 0;
        if(n==2) return Math.abs(arr[n-1]-arr[n-2]);
            int op1 = Math.abs(arr[n-1]-arr[n-2]) +min(arr,n-1);
            int op2 = Math.abs(arr[n-1]-arr[n-3]) +min(arr,n-2);
          int res = Math.min(op1, op2);
          
          return res;
    }
    
    static int dpc(int[] a, int n)
    {
        int[] dp = new int[n];
        
    dp[0]=0;
    dp[1]=Math.abs(a[0]-a[1]);
    for(int i =2;i<n;i++)
    {
             dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);

    }
        
        return dp[n-1];
    }
    
} Main
import java.util.*;
public class Main{
    public static void main(String args[]) {
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    
    for(int i =0; i<n;i++)
    arr[i] = sc.nextInt();
   
      System.out.println(dpc(arr,n));
      
      
    }
    
    static int min(int[] arr, int n)
    { 
        if(n==1) return 0;
        if(n==2) return Math.abs(arr[n-1]-arr[n-2]);
            int op1 = Math.abs(arr[n-1]-arr[n-2]) +min(arr,n-1);
            int op2 = Math.abs(arr[n-1]-arr[n-3]) +min(arr,n-2);
          int res = Math.min(op1, op2);
          
          return res;
    }
    
    static int dpc(int[] a, int n)
    {
        int[] dp = new int[n];
        
    dp[0]=0;
    dp[1]=Math.abs(a[0]-a[1]);
    for(int i =2;i<n;i++)
    {
             dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);

    }
        
        return dp[n-1];
    }
    
}