
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{  
    public static void process()throws IOException
    {
     int n=ni();
     int arr[]=iarr(n);
     if(n==1)
      pn(0);
    else if(n==2)
      pn(Math.abs(arr[1]-arr[0]));
    else
    {
      int dp[]=new int[n];
      dp[0]=0;
      dp[1]=Math.abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     }
     pn(dp[n-1]);
   }
    }     
    
    
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        //oj = System.getProperty("ONLINE_JUDGE") != null;
        //if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
       
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static String nn()throws IOException{return sc.next();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static int[] iarr(int N)throws IOException{int[]ARR=new int[N];for(int i=0;i<N;i++){ARR[i]=ni();}return ARR;}
    static long[] larr(int N)throws IOException{long[]ARR=new long[N];for(int i=0;i<N;i++){ARR[i]=nl();}return ARR;}
    static boolean multipleTC=false;

/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
    
    
    

     import java.util.*; util.* java import java.io.*; io.* java import java.math.*; math.* java public class Main
{  
    public static void process()throws IOException
    {
     int n=ni();
     int arr[]=iarr(n);
     if(n==1)
      pn(0);
    else if(n==2)
      pn(Math.abs(arr[1]-arr[0]));
    else
    {
      int dp[]=new int[n];
      dp[0]=0;
      dp[1]=Math.abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     }
     pn(dp[n-1]);
   }
    }     
    
    
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        //oj = System.getProperty("ONLINE_JUDGE") != null;
        //if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
       
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static String nn()throws IOException{return sc.next();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static int[] iarr(int N)throws IOException{int[]ARR=new int[N];for(int i=0;i<N;i++){ARR[i]=ni();}return ARR;}
    static long[] larr(int N)throws IOException{long[]ARR=new long[N];for(int i=0;i<N;i++){ARR[i]=nl();}return ARR;}
    static boolean multipleTC=false;

/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
} Main static AnotherReader sc; sc static PrintWriter out; out static boolean multipleTC=false; multipleTC false public static void process()throws IOException
    {
     int n=ni();
     int arr[]=iarr(n);
     if(n==1)
      pn(0);
    else if(n==2)
      pn(Math.abs(arr[1]-arr[0]));
    else
    {
      int dp[]=new int[n];
      dp[0]=0;
      dp[1]=Math.abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     }
     pn(dp[n-1]);
   }
    } process {
     int n=ni();
     int arr[]=iarr(n);
     if(n==1)
      pn(0);
    else if(n==2)
      pn(Math.abs(arr[1]-arr[0]));
    else
    {
      int dp[]=new int[n];
      dp[0]=0;
      dp[1]=Math.abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     }
     pn(dp[n-1]);
   }
    } int n=ni(); n ni() ni int arr[]=iarr(n); arr iarr(n) iarr n if(n==1)
      pn(0);
    else if(n==2)
      pn(Math.abs(arr[1]-arr[0]));
    else
    {
      int dp[]=new int[n];
      dp[0]=0;
      dp[1]=Math.abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     }
     pn(dp[n-1]);
   } n==1 n 1 pn(0) pn 0 if(n==2)
      pn(Math.abs(arr[1]-arr[0]));
    else
    {
      int dp[]=new int[n];
      dp[0]=0;
      dp[1]=Math.abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     }
     pn(dp[n-1]);
   } n==2 n 2 pn(Math.abs(arr[1]-arr[0])) pn Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 {
      int dp[]=new int[n];
      dp[0]=0;
      dp[1]=Math.abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     }
     pn(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(arr[1]-arr[0]) dp[1] dp 1 Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     } int i=2; int i=2; i 2 i<n i n i++ i++ i {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     } {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     } dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i])) dp[i] dp i Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i])) Math.min Math dp[i-1]+Math.abs(arr[i-1]-arr[i]) dp[i-1] dp i-1 i 1 Math.abs(arr[i-1]-arr[i]) Math.abs Math arr[i-1]-arr[i] arr[i-1] arr i-1 i 1 arr[i] arr i dp[i-2]+Math.abs(arr[i-2]-arr[i]) dp[i-2] dp i-2 i 2 Math.abs(arr[i-2]-arr[i]) Math.abs Math arr[i-2]-arr[i] arr[i-2] arr i-2 i 2 arr[i] arr i pn(dp[n-1]) pn dp[n-1] dp n-1 n 1 public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        //oj = System.getProperty("ONLINE_JUDGE") != null;
        //if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
       
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    } main {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        //oj = System.getProperty("ONLINE_JUDGE") != null;
        //if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
       
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    } out = new PrintWriter(System.out) out new PrintWriter(System.out) sc=new AnotherReader() sc new AnotherReader() boolean oj = true; oj true long s = System.currentTimeMillis(); s System.currentTimeMillis() System.currentTimeMillis System process() process out.flush() out.flush out if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms"); !oj oj System.out.println(System.currentTimeMillis()-s+"ms") System.out.println System.out System System.out System.currentTimeMillis()-s+"ms" System.currentTimeMillis()-s System.currentTimeMillis() System.currentTimeMillis System s "ms" System.out.close() System.out.close System.out System System.out String[]args args static void pn(Object o){out.println(o);} pn {out.println(o);} out.println(o) out.println out o Object o o static void p(Object o){out.print(o);} p {out.print(o);} out.print(o) out.print out o Object o o static void pni(Object o){out.println(o);System.out.flush();} pni {out.println(o);System.out.flush();} out.println(o) out.println out o System.out.flush() System.out.flush System.out System System.out Object o o static int ni()throws IOException{return sc.nextInt();} ni {return sc.nextInt();} return sc.nextInt(); sc.nextInt() sc.nextInt sc static long nl()throws IOException{return sc.nextLong();} nl {return sc.nextLong();} return sc.nextLong(); sc.nextLong() sc.nextLong sc static double nd()throws IOException{return sc.nextDouble();} nd {return sc.nextDouble();} return sc.nextDouble(); sc.nextDouble() sc.nextDouble sc static String nln()throws IOException{return sc.nextLine();} nln {return sc.nextLine();} return sc.nextLine(); sc.nextLine() sc.nextLine sc static String nn()throws IOException{return sc.next();} nn {return sc.next();} return sc.next(); sc.next() sc.next sc static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);} gcd {return (b==0)?a:gcd(b,a%b);} return (b==0)?a:gcd(b,a%b); (b==0)?a:gcd(b,a%b) (b==0) b 0 a gcd(b,a%b) gcd b a%b a b long a a long b b static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);} gcd {return (b==0)?a:gcd(b,a%b);} return (b==0)?a:gcd(b,a%b); (b==0)?a:gcd(b,a%b) (b==0) b 0 a gcd(b,a%b) gcd b a%b a b int a a int b b static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));} bit {return (n==0)?0:(1+bit(n&(n-1)));} return (n==0)?0:(1+bit(n&(n-1))); (n==0)?0:(1+bit(n&(n-1))) (n==0) n 0 0 (1+bit(n&(n-1))) 1 bit(n&(n-1)) bit n&(n-1) n (n-1) n 1 long n n static int[] iarr(int N)throws IOException{int[]ARR=new int[N];for(int i=0;i<N;i++){ARR[i]=ni();}return ARR;} iarr {int[]ARR=new int[N];for(int i=0;i<N;i++){ARR[i]=ni();}return ARR;} int[]ARR=new int[N]; ARR new int[N] N for(int i=0;i<N;i++){ARR[i]=ni();} int i=0; int i=0; i 0 i<N i N i++ i++ i {ARR[i]=ni();} {ARR[i]=ni();} ARR[i]=ni() ARR[i] ARR i ni() ni return ARR; ARR int N N static long[] larr(int N)throws IOException{long[]ARR=new long[N];for(int i=0;i<N;i++){ARR[i]=nl();}return ARR;} larr {long[]ARR=new long[N];for(int i=0;i<N;i++){ARR[i]=nl();}return ARR;} long[]ARR=new long[N]; ARR new long[N] N for(int i=0;i<N;i++){ARR[i]=nl();} int i=0; int i=0; i 0 i<N i N i++ i++ i {ARR[i]=nl();} {ARR[i]=nl();} ARR[i]=nl() ARR[i] ARR i nl() nl return ARR; ARR int N N     static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}} AnotherReader BufferedReader br; br StringTokenizer st; st AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));} AnotherReader {
    br=new BufferedReader(new InputStreamReader(System.in));} br=new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));} AnotherReader {
    br = new BufferedReader(new FileReader("input.txt"));} br = new BufferedReader(new FileReader("input.txt")) br new BufferedReader(new FileReader("input.txt")) int a a String next()throws IOException{
    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() throws IOException{
    return Integer.parseInt(next());} nextInt {
    return Integer.parseInt(next());} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() throws IOException
    {return Long.parseLong(next());} nextLong {return Long.parseLong(next());} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble()throws IOException { return Double.parseDouble(next()); } nextDouble { return Double.parseDouble(next()); } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine() throws IOException{ 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 public class Main
{  
    public static void process()throws IOException
    {
     int n=ni();
     int arr[]=iarr(n);
     if(n==1)
      pn(0);
    else if(n==2)
      pn(Math.abs(arr[1]-arr[0]));
    else
    {
      int dp[]=new int[n];
      dp[0]=0;
      dp[1]=Math.abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     }
     pn(dp[n-1]);
   }
    }     
    
    
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        //oj = System.getProperty("ONLINE_JUDGE") != null;
        //if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
       
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static String nn()throws IOException{return sc.next();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static int[] iarr(int N)throws IOException{int[]ARR=new int[N];for(int i=0;i<N;i++){ARR[i]=ni();}return ARR;}
    static long[] larr(int N)throws IOException{long[]ARR=new long[N];for(int i=0;i<N;i++){ARR[i]=nl();}return ARR;}
    static boolean multipleTC=false;

/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
} public class Main
{  
    public static void process()throws IOException
    {
     int n=ni();
     int arr[]=iarr(n);
     if(n==1)
      pn(0);
    else if(n==2)
      pn(Math.abs(arr[1]-arr[0]));
    else
    {
      int dp[]=new int[n];
      dp[0]=0;
      dp[1]=Math.abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     }
     pn(dp[n-1]);
   }
    }     
    
    
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        //oj = System.getProperty("ONLINE_JUDGE") != null;
        //if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
       
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static String nn()throws IOException{return sc.next();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static int[] iarr(int N)throws IOException{int[]ARR=new int[N];for(int i=0;i<N;i++){ARR[i]=ni();}return ARR;}
    static long[] larr(int N)throws IOException{long[]ARR=new long[N];for(int i=0;i<N;i++){ARR[i]=nl();}return ARR;}
    static boolean multipleTC=false;

/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
} Main

import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{  
    public static void process()throws IOException
    {
     int n=ni();
     int arr[]=iarr(n);
     if(n==1)
      pn(0);
    else if(n==2)
      pn(Math.abs(arr[1]-arr[0]));
    else
    {
      int dp[]=new int[n];
      dp[0]=0;
      dp[1]=Math.abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
      dp[i]=Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
     }
     pn(dp[n-1]);
   }
    }     
    
    
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        //oj = System.getProperty("ONLINE_JUDGE") != null;
        //if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
       
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static String nn()throws IOException{return sc.next();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static int[] iarr(int N)throws IOException{int[]ARR=new int[N];for(int i=0;i<N;i++){ARR[i]=ni();}return ARR;}
    static long[] larr(int N)throws IOException{long[]ARR=new long[N];for(int i=0;i<N;i++){ARR[i]=nl();}return ARR;}
    static boolean multipleTC=false;

/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
    
    
    

    