import java.io.*;
import java.util.*;
import java.math.*;
import java.math.BigInteger;
class Main
{    
    public static void main(String args[])
    {
        StringBuilder ans=new StringBuilder();
        FastReader in=new FastReader();    
        int N=in.nextInt();
        int A[]=new int[N];
       // Arrays.fill(A,0);
        for(int i=0; i<N; i++)A[i]=in.nextInt();
        //start at 0 and finish at
       // int i=0;
        long cost=0;
        int dp[]=new int[N];
        
        for(int i=0; i<N; i++)
        {
            if(i==0)
            {dp[0]=0;continue;
            }
            if(i==1)
            {
                dp[1]=Math.abs(A[1]-A[0]);
                continue;
            }
           
            dp[i]=Math.min((Math.abs(A[i]-A[i-1])+dp[i-1]),(Math.abs(A[i]-A[i-2])+dp[i-2]));
        }
        System.out.println(dp[N-1]);
    }


    static  long pow(long a,long b)
    {
        long mod=1000000007;
        long pow=1;
        long x=a;
        while(b!=0)
        {
            if((b&1)!=0)pow=(pow*x)%mod;
            x=(x*x)%mod;
            b/=2;
        }
        return pow;
    }

    static int bits(long x)
    {
        int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;
        return (1<<n);
    }

    static long rev(long x)
    {
        int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;

        return ((1<<n)-1)^x;
    }
    //fucntions
    //fucntions
    //fucntions
    //fucntions
    static int[] input(int A[]) //input of Int Array
    {
        FastReader in=new FastReader();
        int N=A.length;
        for(int i=0; i<N; i++)
        {
            A[i]=in.nextInt();
        }
        return A;
    }

    static long[] input(long A[]) //Input of long Array
    {
        FastReader in=new FastReader();
        for(int i=0; i<A.length; i++)A[i]=in.nextLong();
        return A;
    }

    static long lcm(long a,long b)
    {
        return (a*b)/GCD(a,b);
    }

    static long GCD(long a,long b) //wrong output if a ||b are intially zero
    {
        if(b==0)
        {
            return a;
        }
        else return GCD(b,a%b );
    }

    static boolean isPrime(int N)
    {
        for(int i=2; i*i<N; i++)
            if(N%i==0)return false;
        return true;
    }

}
//Code For FastReader
//Code For FastReader
//Code For FastReader
//Code For FastReader
class FastReader
{
    BufferedReader br;
    StringTokenizer st;
    public FastReader()
    {
        br=new BufferedReader(new InputStreamReader(System.in));
    }

    String next()
    {
        while(st==null || !st.hasMoreElements())
        {
            try
            {
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str="";
        try
        {
            str=br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }

} import java.io.*; io.* java import java.util.*; util.* java import java.math.*; math.* java import java.math.BigInteger; BigInteger java.math class Main
{    
    public static void main(String args[])
    {
        StringBuilder ans=new StringBuilder();
        FastReader in=new FastReader();    
        int N=in.nextInt();
        int A[]=new int[N];
       // Arrays.fill(A,0);
        for(int i=0; i<N; i++)A[i]=in.nextInt();
        //start at 0 and finish at
       // int i=0;
        long cost=0;
        int dp[]=new int[N];
        
        for(int i=0; i<N; i++)
        {
            if(i==0)
            {dp[0]=0;continue;
            }
            if(i==1)
            {
                dp[1]=Math.abs(A[1]-A[0]);
                continue;
            }
           
            dp[i]=Math.min((Math.abs(A[i]-A[i-1])+dp[i-1]),(Math.abs(A[i]-A[i-2])+dp[i-2]));
        }
        System.out.println(dp[N-1]);
    }


    static  long pow(long a,long b)
    {
        long mod=1000000007;
        long pow=1;
        long x=a;
        while(b!=0)
        {
            if((b&1)!=0)pow=(pow*x)%mod;
            x=(x*x)%mod;
            b/=2;
        }
        return pow;
    }

    static int bits(long x)
    {
        int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;
        return (1<<n);
    }

    static long rev(long x)
    {
        int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;

        return ((1<<n)-1)^x;
    }
    //fucntions
    //fucntions
    //fucntions
    //fucntions
    static int[] input(int A[]) //input of Int Array
    {
        FastReader in=new FastReader();
        int N=A.length;
        for(int i=0; i<N; i++)
        {
            A[i]=in.nextInt();
        }
        return A;
    }

    static long[] input(long A[]) //Input of long Array
    {
        FastReader in=new FastReader();
        for(int i=0; i<A.length; i++)A[i]=in.nextLong();
        return A;
    }

    static long lcm(long a,long b)
    {
        return (a*b)/GCD(a,b);
    }

    static long GCD(long a,long b) //wrong output if a ||b are intially zero
    {
        if(b==0)
        {
            return a;
        }
        else return GCD(b,a%b );
    }

    static boolean isPrime(int N)
    {
        for(int i=2; i*i<N; i++)
            if(N%i==0)return false;
        return true;
    }

} Main public static void main(String args[])
    {
        StringBuilder ans=new StringBuilder();
        FastReader in=new FastReader();    
        int N=in.nextInt();
        int A[]=new int[N];
       // Arrays.fill(A,0);
        for(int i=0; i<N; i++)A[i]=in.nextInt();
        //start at 0 and finish at
       // int i=0;
        long cost=0;
        int dp[]=new int[N];
        
        for(int i=0; i<N; i++)
        {
            if(i==0)
            {dp[0]=0;continue;
            }
            if(i==1)
            {
                dp[1]=Math.abs(A[1]-A[0]);
                continue;
            }
           
            dp[i]=Math.min((Math.abs(A[i]-A[i-1])+dp[i-1]),(Math.abs(A[i]-A[i-2])+dp[i-2]));
        }
        System.out.println(dp[N-1]);
    } main {
        StringBuilder ans=new StringBuilder();
        FastReader in=new FastReader();    
        int N=in.nextInt();
        int A[]=new int[N];
       // Arrays.fill(A,0);
        for(int i=0; i<N; i++)A[i]=in.nextInt();
        //start at 0 and finish at
       // int i=0;
        long cost=0;
        int dp[]=new int[N];
        
        for(int i=0; i<N; i++)
        {
            if(i==0)
            {dp[0]=0;continue;
            }
            if(i==1)
            {
                dp[1]=Math.abs(A[1]-A[0]);
                continue;
            }
           
            dp[i]=Math.min((Math.abs(A[i]-A[i-1])+dp[i-1]),(Math.abs(A[i]-A[i-2])+dp[i-2]));
        }
        System.out.println(dp[N-1]);
    } StringBuilder ans=new StringBuilder(); ans new StringBuilder() FastReader in=new FastReader(); in new FastReader() int N=in.nextInt(); N in.nextInt() in.nextInt in int A[]=new int[N]; A new int[N] N for(int i=0; i<N; i++)A[i]=in.nextInt(); int i=0; int i=0; i 0 i<N i N i++ i++ i A[i]=in.nextInt(); A[i]=in.nextInt() A[i] A i in.nextInt() in.nextInt in long cost=0; cost 0 int dp[]=new int[N]; dp new int[N] N for(int i=0; i<N; i++)
        {
            if(i==0)
            {dp[0]=0;continue;
            }
            if(i==1)
            {
                dp[1]=Math.abs(A[1]-A[0]);
                continue;
            }
           
            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=0; int i=0; i 0 i<N i N i++ i++ i {
            if(i==0)
            {dp[0]=0;continue;
            }
            if(i==1)
            {
                dp[1]=Math.abs(A[1]-A[0]);
                continue;
            }
           
            dp[i]=Math.min((Math.abs(A[i]-A[i-1])+dp[i-1]),(Math.abs(A[i]-A[i-2])+dp[i-2]));
        } {
            if(i==0)
            {dp[0]=0;continue;
            }
            if(i==1)
            {
                dp[1]=Math.abs(A[1]-A[0]);
                continue;
            }
           
            dp[i]=Math.min((Math.abs(A[i]-A[i-1])+dp[i-1]),(Math.abs(A[i]-A[i-2])+dp[i-2]));
        } if(i==0)
            {dp[0]=0;continue;
            } i==0 i 0 {dp[0]=0;continue;
            } dp[0]=0 dp[0] dp 0 0 continue; if(i==1)
            {
                dp[1]=Math.abs(A[1]-A[0]);
                continue;
            } i==1 i 1 {
                dp[1]=Math.abs(A[1]-A[0]);
                continue;
            } dp[1]=Math.abs(A[1]-A[0]) dp[1] dp 1 Math.abs(A[1]-A[0]) Math.abs Math A[1]-A[0] A[1] A 1 A[0] A 0 continue; 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 System.out.println(dp[N-1]) System.out.println System.out System System.out dp[N-1] dp N-1 N 1 String args[] args static  long pow(long a,long b)
    {
        long mod=1000000007;
        long pow=1;
        long x=a;
        while(b!=0)
        {
            if((b&1)!=0)pow=(pow*x)%mod;
            x=(x*x)%mod;
            b/=2;
        }
        return pow;
    } pow {
        long mod=1000000007;
        long pow=1;
        long x=a;
        while(b!=0)
        {
            if((b&1)!=0)pow=(pow*x)%mod;
            x=(x*x)%mod;
            b/=2;
        }
        return pow;
    } long mod=1000000007; mod 1000000007 long pow=1; pow 1 long x=a; x a while(b!=0)
        {
            if((b&1)!=0)pow=(pow*x)%mod;
            x=(x*x)%mod;
            b/=2;
        } b!=0 b 0 {
            if((b&1)!=0)pow=(pow*x)%mod;
            x=(x*x)%mod;
            b/=2;
        } if((b&1)!=0)pow=(pow*x)%mod; (b&1)!=0 (b&1) b 1 0 pow=(pow*x)%mod pow (pow*x)%mod (pow*x) pow x mod x=(x*x)%mod x (x*x)%mod (x*x) x x mod b/=2 b 2 return pow; pow long a a long b b static int bits(long x)
    {
        int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;
        return (1<<n);
    } bits {
        int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;
        return (1<<n);
    } int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1; n (int)(Math.floor(Math.log(x)/Math.log(2)))+1 (int)(Math.floor(Math.log(x)/Math.log(2))) Math.floor Math Math.log(x)/Math.log(2) Math.log(x) Math.log Math x Math.log(2) Math.log Math 2 1 return (1<<n); (1<<n) 1 n long x x static long rev(long x)
    {
        int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;

        return ((1<<n)-1)^x;
    } rev {
        int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;

        return ((1<<n)-1)^x;
    } int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1; n (int)(Math.floor(Math.log(x)/Math.log(2)))+1 (int)(Math.floor(Math.log(x)/Math.log(2))) Math.floor Math Math.log(x)/Math.log(2) Math.log(x) Math.log Math x Math.log(2) Math.log Math 2 1 return ((1<<n)-1)^x; ((1<<n)-1)^x ((1<<n)-1) (1<<n) 1 n 1 x long x x //fucntions
    //fucntions
    //fucntions
    //fucntions
    static int[] input(int A[]) //input of Int Array
    {
        FastReader in=new FastReader();
        int N=A.length;
        for(int i=0; i<N; i++)
        {
            A[i]=in.nextInt();
        }
        return A;
    } input {
        FastReader in=new FastReader();
        int N=A.length;
        for(int i=0; i<N; i++)
        {
            A[i]=in.nextInt();
        }
        return A;
    } FastReader in=new FastReader(); in new FastReader() int N=A.length; N A.length A A.length for(int i=0; i<N; i++)
        {
            A[i]=in.nextInt();
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            A[i]=in.nextInt();
        } {
            A[i]=in.nextInt();
        } A[i]=in.nextInt() A[i] A i in.nextInt() in.nextInt in return A; A int A[] A static long[] input(long A[]) //Input of long Array
    {
        FastReader in=new FastReader();
        for(int i=0; i<A.length; i++)A[i]=in.nextLong();
        return A;
    } input {
        FastReader in=new FastReader();
        for(int i=0; i<A.length; i++)A[i]=in.nextLong();
        return A;
    } FastReader in=new FastReader(); in new FastReader() for(int i=0; i<A.length; i++)A[i]=in.nextLong(); int i=0; int i=0; i 0 i<A.length i A.length A A.length i++ i++ i A[i]=in.nextLong(); A[i]=in.nextLong() A[i] A i in.nextLong() in.nextLong in return A; A long A[] A static long lcm(long a,long b)
    {
        return (a*b)/GCD(a,b);
    } lcm {
        return (a*b)/GCD(a,b);
    } return (a*b)/GCD(a,b); (a*b)/GCD(a,b) (a*b) a b GCD(a,b) GCD a b long a a long b b static long GCD(long a,long b) //wrong output if a ||b are intially zero
    {
        if(b==0)
        {
            return a;
        }
        else return GCD(b,a%b );
    } GCD {
        if(b==0)
        {
            return a;
        }
        else return GCD(b,a%b );
    } if(b==0)
        {
            return a;
        }
        else return GCD(b,a%b ); b==0 b 0 {
            return a;
        } return a; a return GCD(b,a%b ); GCD(b,a%b ) GCD b a%b a b long a a long b b static boolean isPrime(int N)
    {
        for(int i=2; i*i<N; i++)
            if(N%i==0)return false;
        return true;
    } isPrime {
        for(int i=2; i*i<N; i++)
            if(N%i==0)return false;
        return true;
    } for(int i=2; i*i<N; i++)
            if(N%i==0)return false; int i=2; int i=2; i 2 i*i<N i*i i i N i++ i++ i if(N%i==0)return false; if(N%i==0)return false; N%i==0 N%i N i 0 return false; false return true; true int N N class FastReader
{
    BufferedReader br;
    StringTokenizer st;
    public FastReader()
    {
        br=new BufferedReader(new InputStreamReader(System.in));
    }

    String next()
    {
        while(st==null || !st.hasMoreElements())
        {
            try
            {
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str="";
        try
        {
            str=br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }

} FastReader BufferedReader br; br StringTokenizer st; st public FastReader()
    {
        br=new BufferedReader(new InputStreamReader(System.in));
    } FastReader {
        br=new BufferedReader(new InputStreamReader(System.in));
    } br=new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next()
    {
        while(st==null || !st.hasMoreElements())
        {
            try
            {
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    } next {
        while(st==null || !st.hasMoreElements())
        {
            try
            {
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    } while(st==null || !st.hasMoreElements())
        {
            try
            {
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        } st==null || !st.hasMoreElements() st==null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
            try
            {
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        } try
            {
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e)
            {
                e.printStackTrace();
            } catch(IOException e)
            {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                st=new StringTokenizer(br.readLine());
            } st=new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt()
    {
        return Integer.parseInt(next());
    } nextInt {
        return Integer.parseInt(next());
    } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong()
    {
        return Long.parseLong(next());
    } nextLong {
        return Long.parseLong(next());
    } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble()
    {
        return Double.parseDouble(next());
    } nextDouble {
        return Double.parseDouble(next());
    } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine()
    {
        String str="";
        try
        {
            str=br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    } nextLine {
        String str="";
        try
        {
            str=br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    } String str=""; str "" try
        {
            str=br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        } catch (IOException e)
        {
            e.printStackTrace();
        } IOException e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            str=br.readLine();
        } str=br.readLine() str br.readLine() br.readLine br return str; str
import java.io.*;
import java.util.*;
import java.math.*;
import java.math.BigInteger;
class Main
{    
    public static void main(String args[])
    {
        StringBuilder ans=new StringBuilder();
        FastReader in=new FastReader();    
        int N=in.nextInt();
        int A[]=new int[N];
       // Arrays.fill(A,0);
        for(int i=0; i<N; i++)A[i]=in.nextInt();
        //start at 0 and finish at
       // int i=0;
        long cost=0;
        int dp[]=new int[N];
        
        for(int i=0; i<N; i++)
        {
            if(i==0)
            {dp[0]=0;continue;
            }
            if(i==1)
            {
                dp[1]=Math.abs(A[1]-A[0]);
                continue;
            }
           
            dp[i]=Math.min((Math.abs(A[i]-A[i-1])+dp[i-1]),(Math.abs(A[i]-A[i-2])+dp[i-2]));
        }
        System.out.println(dp[N-1]);
    }


    static  long pow(long a,long b)
    {
        long mod=1000000007;
        long pow=1;
        long x=a;
        while(b!=0)
        {
            if((b&1)!=0)pow=(pow*x)%mod;
            x=(x*x)%mod;
            b/=2;
        }
        return pow;
    }

    static int bits(long x)
    {
        int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;
        return (1<<n);
    }

    static long rev(long x)
    {
        int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;

        return ((1<<n)-1)^x;
    }
    //fucntions
    //fucntions
    //fucntions
    //fucntions
    static int[] input(int A[]) //input of Int Array
    {
        FastReader in=new FastReader();
        int N=A.length;
        for(int i=0; i<N; i++)
        {
            A[i]=in.nextInt();
        }
        return A;
    }

    static long[] input(long A[]) //Input of long Array
    {
        FastReader in=new FastReader();
        for(int i=0; i<A.length; i++)A[i]=in.nextLong();
        return A;
    }

    static long lcm(long a,long b)
    {
        return (a*b)/GCD(a,b);
    }

    static long GCD(long a,long b) //wrong output if a ||b are intially zero
    {
        if(b==0)
        {
            return a;
        }
        else return GCD(b,a%b );
    }

    static boolean isPrime(int N)
    {
        for(int i=2; i*i<N; i++)
            if(N%i==0)return false;
        return true;
    }

}
//Code For FastReader
//Code For FastReader
//Code For FastReader
//Code For FastReader
class FastReader
{
    BufferedReader br;
    StringTokenizer st;
    public FastReader()
    {
        br=new BufferedReader(new InputStreamReader(System.in));
    }

    String next()
    {
        while(st==null || !st.hasMoreElements())
        {
            try
            {
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str="";
        try
        {
            str=br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }

}