import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
     Scanner sc = new Scanner(System.in);
     int n = 0;
     if(sc.hasNextInt())
            n = sc.nextInt();
        int[] dp = new int[n];
     for(int i = 0 ; i < n ; i++)
     {
         dp[i] = sc.nextInt();
     }
     int[] x = new int[n];
     Arrays.fill(x,Integer.MAX_VALUE);
     x[0] = 0;
     for(int i = 0 ; i < n ; i++)
     {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     }
     System.out.println(x[n-1]);


    }
} import java.util.*; util.* java public class Main
{
    public static void main(String[] args)
    {
     Scanner sc = new Scanner(System.in);
     int n = 0;
     if(sc.hasNextInt())
            n = sc.nextInt();
        int[] dp = new int[n];
     for(int i = 0 ; i < n ; i++)
     {
         dp[i] = sc.nextInt();
     }
     int[] x = new int[n];
     Arrays.fill(x,Integer.MAX_VALUE);
     x[0] = 0;
     for(int i = 0 ; i < n ; i++)
     {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     }
     System.out.println(x[n-1]);


    }
} Main public static void main(String[] args)
    {
     Scanner sc = new Scanner(System.in);
     int n = 0;
     if(sc.hasNextInt())
            n = sc.nextInt();
        int[] dp = new int[n];
     for(int i = 0 ; i < n ; i++)
     {
         dp[i] = sc.nextInt();
     }
     int[] x = new int[n];
     Arrays.fill(x,Integer.MAX_VALUE);
     x[0] = 0;
     for(int i = 0 ; i < n ; i++)
     {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     }
     System.out.println(x[n-1]);


    } main {
     Scanner sc = new Scanner(System.in);
     int n = 0;
     if(sc.hasNextInt())
            n = sc.nextInt();
        int[] dp = new int[n];
     for(int i = 0 ; i < n ; i++)
     {
         dp[i] = sc.nextInt();
     }
     int[] x = new int[n];
     Arrays.fill(x,Integer.MAX_VALUE);
     x[0] = 0;
     for(int i = 0 ; i < n ; i++)
     {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     }
     System.out.println(x[n-1]);


    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = 0; n 0 if(sc.hasNextInt())
            n = sc.nextInt(); sc.hasNextInt() sc.hasNextInt sc n = sc.nextInt() n sc.nextInt() sc.nextInt sc int[] dp = new int[n]; dp new int[n] n for(int i = 0 ; i < n ; i++)
     {
         dp[i] = sc.nextInt();
     } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
         dp[i] = sc.nextInt();
     } {
         dp[i] = sc.nextInt();
     } dp[i] = sc.nextInt() dp[i] dp i sc.nextInt() sc.nextInt sc int[] x = new int[n]; x new int[n] n Arrays.fill(x,Integer.MAX_VALUE) Arrays.fill Arrays x Integer.MAX_VALUE Integer Integer.MAX_VALUE x[0] = 0 x[0] x 0 0 for(int i = 0 ; i < n ; i++)
     {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     } {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     } for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         } int j = i+1 ; int j = i+1 ; j i+1 i 1 j < i+3 j i+3 i 3 j++ j++ j {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         } {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         } if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             } j < n j n {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             } x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j])) x[j] x j Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j])) Math.min Math x[j] x j x[i]+Math.abs(dp[i]- dp[j]) x[i] x i Math.abs(dp[i]- dp[j]) Math.abs Math dp[i]- dp[j] dp[i] dp i dp[j] dp j System.out.println(x[n-1]) System.out.println System.out System System.out x[n-1] x n-1 n 1 String[] args args public class Main
{
    public static void main(String[] args)
    {
     Scanner sc = new Scanner(System.in);
     int n = 0;
     if(sc.hasNextInt())
            n = sc.nextInt();
        int[] dp = new int[n];
     for(int i = 0 ; i < n ; i++)
     {
         dp[i] = sc.nextInt();
     }
     int[] x = new int[n];
     Arrays.fill(x,Integer.MAX_VALUE);
     x[0] = 0;
     for(int i = 0 ; i < n ; i++)
     {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     }
     System.out.println(x[n-1]);


    }
} public class Main
{
    public static void main(String[] args)
    {
     Scanner sc = new Scanner(System.in);
     int n = 0;
     if(sc.hasNextInt())
            n = sc.nextInt();
        int[] dp = new int[n];
     for(int i = 0 ; i < n ; i++)
     {
         dp[i] = sc.nextInt();
     }
     int[] x = new int[n];
     Arrays.fill(x,Integer.MAX_VALUE);
     x[0] = 0;
     for(int i = 0 ; i < n ; i++)
     {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     }
     System.out.println(x[n-1]);


    }
} Main
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
     Scanner sc = new Scanner(System.in);
     int n = 0;
     if(sc.hasNextInt())
            n = sc.nextInt();
        int[] dp = new int[n];
     for(int i = 0 ; i < n ; i++)
     {
         dp[i] = sc.nextInt();
     }
     int[] x = new int[n];
     Arrays.fill(x,Integer.MAX_VALUE);
     x[0] = 0;
     for(int i = 0 ; i < n ; i++)
     {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     }
     System.out.println(x[n-1]);


    }
}
