import java.io.*;
import java.util.*;

public class Main{

        public static void main(String[] args) throws Exception{

            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;

            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);

            Task solver = new Task();
            solver.solve(in,out);
            out.close();
        }

        static class Task{

            public void solve(InputReader in, PrintWriter out){

                int n = in.nextInt();
                int[] costs = new int[n];
                long[] result = new long[n];

                for(int i = 0;i<n;i++){
                    costs[i] = in.nextInt();
                }

                Arrays.fill(result, Long.MIN_VALUE);
                //out.println(go(costs, 0));
                out.println(goIter(costs, result, 0));
            }

            // public int goRec(int[] costs, int step){

            //     if(step >= costs.length)
            //         return Integer.MAX_VALUE;

            //     if(step == costs.length-1)
            //         return 0;

            //     int one_step_value = go(costs, step+1);
            //     if(step < costs.length - 1)
            //         one_step_value += Math.abs(costs[step] - costs[step+1]);
            //     int two_steps_value = go(costs, step+2);
            //     if(step < costs.length - 2)
            //         two_steps_value += Math.abs(costs[step] - costs[step+2]);

            //     return (result[step] = Math.min(one_step_value, two_steps_value));

            // }

            public long goIter(int[] costs, long[] result, int step){
                if(step >= costs.length)
                    return Long.MAX_VALUE;

                if(result[step] != Long.MIN_VALUE)
                    return result[step];

                if(step == costs.length-1)
                    return 0;

                long one_step_value = goIter(costs, result, step+1);
                if(step < costs.length - 1)
                    one_step_value += Math.abs(costs[step] - costs[step+1]);
                long two_steps_value = goIter(costs, result, step+2);
                if(step < costs.length - 2)
                    two_steps_value += Math.abs(costs[step] - costs[step+2]);

                return (result[step] = Math.min(one_step_value, two_steps_value));
            }
        }

        static class InputReader{

            BufferedReader reader;
            StringTokenizer tokenizer;

            public InputReader(InputStream inputStream){

                reader = new BufferedReader(new InputStreamReader(inputStream));
                tokenizer = null;

            }

            public String next(){
                while(tokenizer == null || !tokenizer.hasMoreTokens()){
                    try{
                        tokenizer = new StringTokenizer(reader.readLine());
                    }
                    catch(IOException e){
                        throw new RuntimeException(e);
                    }
                }

                return tokenizer.nextToken();
            }

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


Measured memory_bytes: 49360