import java.util.*;
import java.io.*;
public class Main
{   
    static int arr[]=new int[100008];
    static int dp[]=new int[100008];
    public static int getAns(int arr[],int index,int n)
      {
          if(index>=n)return 0;
          if(dp[index]!=-1)return dp[index];
          int a=Integer.MAX_VALUE,b=Integer.MAX_VALUE;
          if(index+1<=n)
             a=Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n);
          if(index+2<=n)
            b=Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n);
          return dp[index]=Math.min(a,b);
      }
	public static void main(String[] args)throws IOException {
		FastReader kb=new FastReader();
        int n=kb.nextInt();
        Arrays.fill(dp,-1);
        for(int i=1;i<=n;i++)
	     {
	         arr[i]=kb.nextInt();
	     }
	    System.out.println(getAns(arr,1,n));
	}
	static 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.util.*; util.* java import java.io.*; io.* java public class Main
{   
    static int arr[]=new int[100008];
    static int dp[]=new int[100008];
    public static int getAns(int arr[],int index,int n)
      {
          if(index>=n)return 0;
          if(dp[index]!=-1)return dp[index];
          int a=Integer.MAX_VALUE,b=Integer.MAX_VALUE;
          if(index+1<=n)
             a=Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n);
          if(index+2<=n)
            b=Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n);
          return dp[index]=Math.min(a,b);
      }
	public static void main(String[] args)throws IOException {
		FastReader kb=new FastReader();
        int n=kb.nextInt();
        Arrays.fill(dp,-1);
        for(int i=1;i<=n;i++)
	     {
	         arr[i]=kb.nextInt();
	     }
	    System.out.println(getAns(arr,1,n));
	}
	static 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; 
        } 
    } 
  
} Main static int arr[]=new int[100008]; arr new int[100008] 100008 static int dp[]=new int[100008]; dp new int[100008] 100008 public static int getAns(int arr[],int index,int n)
      {
          if(index>=n)return 0;
          if(dp[index]!=-1)return dp[index];
          int a=Integer.MAX_VALUE,b=Integer.MAX_VALUE;
          if(index+1<=n)
             a=Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n);
          if(index+2<=n)
            b=Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n);
          return dp[index]=Math.min(a,b);
      } getAns {
          if(index>=n)return 0;
          if(dp[index]!=-1)return dp[index];
          int a=Integer.MAX_VALUE,b=Integer.MAX_VALUE;
          if(index+1<=n)
             a=Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n);
          if(index+2<=n)
            b=Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n);
          return dp[index]=Math.min(a,b);
      } if(index>=n)return 0; index>=n index n return 0; 0 if(dp[index]!=-1)return dp[index]; dp[index]!=-1 dp[index] dp index -1 1 return dp[index]; dp[index] dp index int a=Integer.MAX_VALUE a Integer.MAX_VALUE Integer Integer.MAX_VALUE b=Integer.MAX_VALUE; b Integer.MAX_VALUE Integer Integer.MAX_VALUE if(index+1<=n)
             a=Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n); index+1<=n index+1 index 1 n a=Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n) a Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n) Math.abs(arr[index+1]-arr[index]) Math.abs Math arr[index+1]-arr[index] arr[index+1] arr index+1 index 1 arr[index] arr index getAns(arr,index+1,n) getAns arr index+1 index 1 n if(index+2<=n)
            b=Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n); index+2<=n index+2 index 2 n b=Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n) b Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n) Math.abs(arr[index+2]-arr[index]) Math.abs Math arr[index+2]-arr[index] arr[index+2] arr index+2 index 2 arr[index] arr index getAns(arr,index+2,n) getAns arr index+2 index 2 n return dp[index]=Math.min(a,b); dp[index]=Math.min(a,b) dp[index] dp index Math.min(a,b) Math.min Math a b int arr[] arr int index index int n n public static void main(String[] args)throws IOException {
		FastReader kb=new FastReader();
        int n=kb.nextInt();
        Arrays.fill(dp,-1);
        for(int i=1;i<=n;i++)
	     {
	         arr[i]=kb.nextInt();
	     }
	    System.out.println(getAns(arr,1,n));
	} main {
		FastReader kb=new FastReader();
        int n=kb.nextInt();
        Arrays.fill(dp,-1);
        for(int i=1;i<=n;i++)
	     {
	         arr[i]=kb.nextInt();
	     }
	    System.out.println(getAns(arr,1,n));
	} FastReader kb=new FastReader(); kb new FastReader() int n=kb.nextInt(); n kb.nextInt() kb.nextInt kb Arrays.fill(dp,-1) Arrays.fill Arrays dp -1 1 for(int i=1;i<=n;i++)
	     {
	         arr[i]=kb.nextInt();
	     } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
	         arr[i]=kb.nextInt();
	     } {
	         arr[i]=kb.nextInt();
	     } arr[i]=kb.nextInt() arr[i] arr i kb.nextInt() kb.nextInt kb System.out.println(getAns(arr,1,n)) System.out.println System.out System System.out getAns(arr,1,n) getAns arr 1 n String[] args args static 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 public class Main
{   
    static int arr[]=new int[100008];
    static int dp[]=new int[100008];
    public static int getAns(int arr[],int index,int n)
      {
          if(index>=n)return 0;
          if(dp[index]!=-1)return dp[index];
          int a=Integer.MAX_VALUE,b=Integer.MAX_VALUE;
          if(index+1<=n)
             a=Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n);
          if(index+2<=n)
            b=Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n);
          return dp[index]=Math.min(a,b);
      }
	public static void main(String[] args)throws IOException {
		FastReader kb=new FastReader();
        int n=kb.nextInt();
        Arrays.fill(dp,-1);
        for(int i=1;i<=n;i++)
	     {
	         arr[i]=kb.nextInt();
	     }
	    System.out.println(getAns(arr,1,n));
	}
	static 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; 
        } 
    } 
  
} public class Main
{   
    static int arr[]=new int[100008];
    static int dp[]=new int[100008];
    public static int getAns(int arr[],int index,int n)
      {
          if(index>=n)return 0;
          if(dp[index]!=-1)return dp[index];
          int a=Integer.MAX_VALUE,b=Integer.MAX_VALUE;
          if(index+1<=n)
             a=Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n);
          if(index+2<=n)
            b=Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n);
          return dp[index]=Math.min(a,b);
      }
	public static void main(String[] args)throws IOException {
		FastReader kb=new FastReader();
        int n=kb.nextInt();
        Arrays.fill(dp,-1);
        for(int i=1;i<=n;i++)
	     {
	         arr[i]=kb.nextInt();
	     }
	    System.out.println(getAns(arr,1,n));
	}
	static 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; 
        } 
    } 
  
} Main
import java.util.*;
import java.io.*;
public class Main
{   
    static int arr[]=new int[100008];
    static int dp[]=new int[100008];
    public static int getAns(int arr[],int index,int n)
      {
          if(index>=n)return 0;
          if(dp[index]!=-1)return dp[index];
          int a=Integer.MAX_VALUE,b=Integer.MAX_VALUE;
          if(index+1<=n)
             a=Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n);
          if(index+2<=n)
            b=Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n);
          return dp[index]=Math.min(a,b);
      }
	public static void main(String[] args)throws IOException {
		FastReader kb=new FastReader();
        int n=kb.nextInt();
        Arrays.fill(dp,-1);
        for(int i=1;i<=n;i++)
	     {
	         arr[i]=kb.nextInt();
	     }
	    System.out.println(getAns(arr,1,n));
	}
	static 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; 
        } 
    } 
  
}











