import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;
//0/26 done
public class Main { //CHANGE TO MAIN WHEN SUBMITTING
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) a[i] = in.nextInt();
        int[] dp = new int[n];
        Arrays.fill(dp,(int)1e5);
        dp[0] = 0;
        if(dp.length==1){
            out.print(0);
        }
        else{
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            }
            out.print(dp[n-1]);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}
 import java.io.*; io.* java import java.lang.*; lang.* java import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.BufferedReader; BufferedReader java.io import java.io.OutputStream; OutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.io.IOException; IOException java.io import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util import java.math.BigInteger; BigInteger java.math public class Main { //CHANGE TO MAIN WHEN SUBMITTING
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) a[i] = in.nextInt();
        int[] dp = new int[n];
        Arrays.fill(dp,(int)1e5);
        dp[0] = 0;
        if(dp.length==1){
            out.print(0);
        }
        else{
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            }
            out.print(dp[n-1]);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
} Main static InputReader in = new InputReader(System.in); in new InputReader(System.in) static PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) public static void main(String[] args) {
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) a[i] = in.nextInt();
        int[] dp = new int[n];
        Arrays.fill(dp,(int)1e5);
        dp[0] = 0;
        if(dp.length==1){
            out.print(0);
        }
        else{
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            }
            out.print(dp[n-1]);
        }
        out.close();
    } main {
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) a[i] = in.nextInt();
        int[] dp = new int[n];
        Arrays.fill(dp,(int)1e5);
        dp[0] = 0;
        if(dp.length==1){
            out.print(0);
        }
        else{
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            }
            out.print(dp[n-1]);
        }
        out.close();
    } 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 int[] dp = new int[n]; dp new int[n] n Arrays.fill(dp,(int)1e5) Arrays.fill Arrays dp (int)1e5 dp[0] = 0 dp[0] dp 0 0 if(dp.length==1){
            out.print(0);
        }
        else{
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            }
            out.print(dp[n-1]);
        } dp.length==1 dp.length dp dp.length 1 {
            out.print(0);
        } out.print(0) out.print out 0 {
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            }
            out.print(dp[n-1]);
        } 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 for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            } int i = 2; int i = 2; i 2 i<n i n i++ i++ i {
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            } {
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            } dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]) dp[i] dp i Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]) Math.min Math Math.abs(a[i-1]-a[i])+dp[i-1] Math.abs(a[i-1]-a[i]) Math.abs Math a[i-1]-a[i] a[i-1] a i-1 i 1 a[i] a i dp[i-1] dp i-1 i 1 Math.abs(a[i-2]-a[i])+dp[i-2] Math.abs(a[i-2]-a[i]) Math.abs Math a[i-2]-a[i] a[i-2] a i-2 i 2 a[i] a i dp[i-2] dp i-2 i 2 out.print(dp[n-1]) out.print out dp[n-1] dp n-1 n 1 out.close() out.close out String[] args args static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    } InputReader public BufferedReader reader; reader public StringTokenizer tokenizer; tokenizer public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        } InputReader {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        } reader = new BufferedReader(new InputStreamReader(stream), 32768) reader new BufferedReader(new InputStreamReader(stream), 32768) tokenizer = null tokenizer null InputStream stream stream public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } next {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer public int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        } nextLine {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        } try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            } Exception e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                return reader.readLine();
            } return reader.readLine(); reader.readLine() reader.readLine reader return null; null public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        } hasNext {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        } String next = null; next null try {
                next = reader.readLine();
            } catch (Exception e) {
            } catch (Exception e) {
            } Exception e {
            } {
                next = reader.readLine();
            } next = reader.readLine() next reader.readLine() reader.readLine reader if (next == null) {
                return false;
            } next == null next null {
                return false;
            } return false; false tokenizer = new StringTokenizer(next) tokenizer new StringTokenizer(next) return true; true public BigInteger nextBigInteger() {
            return new BigInteger(next());
        } nextBigInteger {
            return new BigInteger(next());
        } return new BigInteger(next()); new BigInteger(next()) public class Main { //CHANGE TO MAIN WHEN SUBMITTING
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) a[i] = in.nextInt();
        int[] dp = new int[n];
        Arrays.fill(dp,(int)1e5);
        dp[0] = 0;
        if(dp.length==1){
            out.print(0);
        }
        else{
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            }
            out.print(dp[n-1]);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
} public class Main { //CHANGE TO MAIN WHEN SUBMITTING
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) a[i] = in.nextInt();
        int[] dp = new int[n];
        Arrays.fill(dp,(int)1e5);
        dp[0] = 0;
        if(dp.length==1){
            out.print(0);
        }
        else{
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            }
            out.print(dp[n-1]);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
} Main
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;
//0/26 done
public class Main { //CHANGE TO MAIN WHEN SUBMITTING
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) a[i] = in.nextInt();
        int[] dp = new int[n];
        Arrays.fill(dp,(int)1e5);
        dp[0] = 0;
        if(dp.length==1){
            out.print(0);
        }
        else{
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            }
            out.print(dp[n-1]);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}

