import java.util.*;
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();
        }
        int min = Integer.MAX_VALUE;
        int res[] =new int[n];
        Arrays.fill(res,Integer.MAX_VALUE);
        res[0]=0;
        for(int i=1;i<n;i++)
        {
            // int one =Integer.MAX_VALUE;
            // int two =Integer.MAX_VALUE;
            if(i-1>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]);
            }
            if(i-2>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]);
            }
        }
        System.out.println(res[n-1]);
    }
} import java.util.*; util.* java 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();
        }
        int min = Integer.MAX_VALUE;
        int res[] =new int[n];
        Arrays.fill(res,Integer.MAX_VALUE);
        res[0]=0;
        for(int i=1;i<n;i++)
        {
            // int one =Integer.MAX_VALUE;
            // int two =Integer.MAX_VALUE;
            if(i-1>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]);
            }
            if(i-2>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]);
            }
        }
        System.out.println(res[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();
        }
        int min = Integer.MAX_VALUE;
        int res[] =new int[n];
        Arrays.fill(res,Integer.MAX_VALUE);
        res[0]=0;
        for(int i=1;i<n;i++)
        {
            // int one =Integer.MAX_VALUE;
            // int two =Integer.MAX_VALUE;
            if(i-1>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]);
            }
            if(i-2>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]);
            }
        }
        System.out.println(res[n-1]);
    } 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();
        }
        int min = Integer.MAX_VALUE;
        int res[] =new int[n];
        Arrays.fill(res,Integer.MAX_VALUE);
        res[0]=0;
        for(int i=1;i<n;i++)
        {
            // int one =Integer.MAX_VALUE;
            // int two =Integer.MAX_VALUE;
            if(i-1>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]);
            }
            if(i-2>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]);
            }
        }
        System.out.println(res[n-1]);
    } 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]=sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE int res[] =new int[n]; res new int[n] n Arrays.fill(res,Integer.MAX_VALUE) Arrays.fill Arrays res Integer.MAX_VALUE Integer Integer.MAX_VALUE res[0]=0 res[0] res 0 0 for(int i=1;i<n;i++)
        {
            // int one =Integer.MAX_VALUE;
            // int two =Integer.MAX_VALUE;
            if(i-1>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]);
            }
            if(i-2>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]);
            }
        } int i=1; int i=1; i 1 i<n i n i++ i++ i {
            // int one =Integer.MAX_VALUE;
            // int two =Integer.MAX_VALUE;
            if(i-1>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]);
            }
            if(i-2>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]);
            }
        } {
            // int one =Integer.MAX_VALUE;
            // int two =Integer.MAX_VALUE;
            if(i-1>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]);
            }
            if(i-2>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]);
            }
        } if(i-1>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]);
            } i-1>=0 i-1 i 1 0 {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]);
            } res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]) res[i] res i Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]) Math.min Math Math.abs(arr[i]-arr[i-1])+res[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 res[i-1] res i-1 i 1 res[i] res i if(i-2>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]);
            } i-2>=0 i-2 i 2 0 {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]);
            } res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]) res[i] res i Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]) Math.min Math Math.abs(arr[i]-arr[i-2])+res[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 res[i-2] res i-2 i 2 res[i] res i System.out.println(res[n-1]) System.out.println System.out System System.out res[n-1] res n-1 n 1 String [] args args
import java.util.*;
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();
        }
        int min = Integer.MAX_VALUE;
        int res[] =new int[n];
        Arrays.fill(res,Integer.MAX_VALUE);
        res[0]=0;
        for(int i=1;i<n;i++)
        {
            // int one =Integer.MAX_VALUE;
            // int two =Integer.MAX_VALUE;
            if(i-1>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-1])+res[i-1],res[i]);
            }
            if(i-2>=0)
            {
                res[i] = Math.min(Math.abs(arr[i]-arr[i-2])+res[i-2],res[i]);
            }
        }
        System.out.println(res[n-1]);
    }
}