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

public class Main {

    public static void main(String[] args) throws Exception {
        pw = new PrintWriter(System.out);
        sc = new MScanner(System.in);
        int n = sc.nextInt();
        int[] heights = new int[n+1];
        for(int i = 1; i <= n; ++i){
            heights[i] = sc.nextInt();
        }
        int[] dp = new int[n+1];
        heights[0] = heights[1];
        for(int pos = 2; pos <= n; ++pos){
            dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]);
        }
        pw.println(dp[n]);
        pw.flush();
    }
    static PrintWriter pw;
    static MScanner  sc;
    static class MScanner {
        StringTokenizer st;
        BufferedReader br;
        public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public MScanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public int[] intArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public long[] longArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public int[] intSortedArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public long[] longSortedArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public Integer[] IntegerArr(int n) throws IOException {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public Long[] LongArr(int n) throws IOException {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
    }
    static void shuffle(int[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
    static void shuffle(long[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {

    public static void main(String[] args) throws Exception {
        pw = new PrintWriter(System.out);
        sc = new MScanner(System.in);
        int n = sc.nextInt();
        int[] heights = new int[n+1];
        for(int i = 1; i <= n; ++i){
            heights[i] = sc.nextInt();
        }
        int[] dp = new int[n+1];
        heights[0] = heights[1];
        for(int pos = 2; pos <= n; ++pos){
            dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]);
        }
        pw.println(dp[n]);
        pw.flush();
    }
    static PrintWriter pw;
    static MScanner  sc;
    static class MScanner {
        StringTokenizer st;
        BufferedReader br;
        public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public MScanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public int[] intArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public long[] longArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public int[] intSortedArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public long[] longSortedArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public Integer[] IntegerArr(int n) throws IOException {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public Long[] LongArr(int n) throws IOException {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
    }
    static void shuffle(int[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
    static void shuffle(long[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
} Main static PrintWriter pw; pw static MScanner  sc; sc public static void main(String[] args) throws Exception {
        pw = new PrintWriter(System.out);
        sc = new MScanner(System.in);
        int n = sc.nextInt();
        int[] heights = new int[n+1];
        for(int i = 1; i <= n; ++i){
            heights[i] = sc.nextInt();
        }
        int[] dp = new int[n+1];
        heights[0] = heights[1];
        for(int pos = 2; pos <= n; ++pos){
            dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]);
        }
        pw.println(dp[n]);
        pw.flush();
    } main {
        pw = new PrintWriter(System.out);
        sc = new MScanner(System.in);
        int n = sc.nextInt();
        int[] heights = new int[n+1];
        for(int i = 1; i <= n; ++i){
            heights[i] = sc.nextInt();
        }
        int[] dp = new int[n+1];
        heights[0] = heights[1];
        for(int pos = 2; pos <= n; ++pos){
            dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]);
        }
        pw.println(dp[n]);
        pw.flush();
    } pw = new PrintWriter(System.out) pw new PrintWriter(System.out) sc = new MScanner(System.in) sc new MScanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] heights = new int[n+1]; heights new int[n+1] n+1 n 1 for(int i = 1; i <= n; ++i){
            heights[i] = sc.nextInt();
        } int i = 1; int i = 1; i 1 i <= n i n ++i ++i i {
            heights[i] = sc.nextInt();
        } {
            heights[i] = sc.nextInt();
        } heights[i] = sc.nextInt() heights[i] heights i sc.nextInt() sc.nextInt sc int[] dp = new int[n+1]; dp new int[n+1] n+1 n 1 heights[0] = heights[1] heights[0] heights 0 heights[1] heights 1 for(int pos = 2; pos <= n; ++pos){
            dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]);
        } int pos = 2; int pos = 2; pos 2 pos <= n pos n ++pos ++pos pos {
            dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]);
        } {
            dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]);
        } dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]) dp[pos] dp pos Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]) Math.min Math Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2] Math.abs(heights[pos] - heights[pos - 2]) Math.abs Math heights[pos] - heights[pos - 2] heights[pos] heights pos heights[pos - 2] heights pos - 2 pos 2 dp[pos - 2] dp pos - 2 pos 2 Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1] Math.abs(heights[pos] - heights[pos - 1]) Math.abs Math heights[pos] - heights[pos - 1] heights[pos] heights pos heights[pos - 1] heights pos - 1 pos 1 dp[pos - 1] dp pos - 1 pos 1 pw.println(dp[n]) pw.println pw dp[n] dp n pw.flush() pw.flush pw String[] args args static void shuffle(int[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    } shuffle {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    } for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        } int i=0; int i=0; i 0 i<in.length i in.length in in.length i++ i++ i {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        } {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        } int idx=(int)(Math.random()*in.length); idx (int)(Math.random()*in.length) Math.random() Math.random Math in.length in in.length int tmp=in[i]; tmp in[i] in i in[i]=in[idx] in[i] in i in[idx] in idx in[idx]=tmp in[idx] in idx tmp int[]in in static void shuffle(long[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    } shuffle {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    } for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        } int i=0; int i=0; i 0 i<in.length i in.length in in.length i++ i++ i {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        } {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        } int idx=(int)(Math.random()*in.length); idx (int)(Math.random()*in.length) Math.random() Math.random Math in.length in in.length long tmp=in[i]; tmp in[i] in i in[i]=in[idx] in[i] in i in[idx] in idx in[idx]=tmp in[idx] in idx tmp long[]in in static class MScanner {
        StringTokenizer st;
        BufferedReader br;
        public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public MScanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public int[] intArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public long[] longArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public int[] intSortedArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public long[] longSortedArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public Integer[] IntegerArr(int n) throws IOException {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public Long[] LongArr(int n) throws IOException {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
    } MScanner StringTokenizer st; st BufferedReader br; br public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        } MScanner {
            br = new BufferedReader(new InputStreamReader(system));
        } br = new BufferedReader(new InputStreamReader(system)) br new BufferedReader(new InputStreamReader(system)) InputStream system system public MScanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        } MScanner {
            br = new BufferedReader(new FileReader(file));
        } br = new BufferedReader(new FileReader(file)) br new BufferedReader(new FileReader(file)) String file file public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        } while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine()); st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st public int[] intArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        } intArr {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        } int[]in=new int[n]; in new int[n] n for(int i=0;i<n;i++)in[i]=nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i in[i]=nextInt(); in[i]=nextInt() in[i] in i nextInt() nextInt return in; in int n n public long[] longArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        } longArr {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        } long[]in=new long[n]; in new long[n] n for(int i=0;i<n;i++)in[i]=nextLong(); int i=0; int i=0; i 0 i<n i n i++ i++ i in[i]=nextLong(); in[i]=nextLong() in[i] in i nextLong() nextLong return in; in int n n public int[] intSortedArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        } intSortedArr {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        } int[]in=new int[n]; in new int[n] n for(int i=0;i<n;i++)in[i]=nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i in[i]=nextInt(); in[i]=nextInt() in[i] in i nextInt() nextInt shuffle(in) shuffle in Arrays.sort(in) Arrays.sort Arrays in return in; in int n n public long[] longSortedArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        } longSortedArr {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        } long[]in=new long[n]; in new long[n] n for(int i=0;i<n;i++)in[i]=nextLong(); int i=0; int i=0; i 0 i<n i n i++ i++ i in[i]=nextLong(); in[i]=nextLong() in[i] in i nextLong() nextLong shuffle(in) shuffle in Arrays.sort(in) Arrays.sort Arrays in return in; in int n n public Integer[] IntegerArr(int n) throws IOException {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        } IntegerArr {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        } Integer[]in=new Integer[n]; in new Integer[n] n for(int i=0;i<n;i++)in[i]=nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i in[i]=nextInt(); in[i]=nextInt() in[i] in i nextInt() nextInt return in; in int n n public Long[] LongArr(int n) throws IOException {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        } LongArr {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        } Long[]in=new Long[n]; in new Long[n] n for(int i=0;i<n;i++)in[i]=nextLong(); int i=0; int i=0; i 0 i<n i n i++ i++ i in[i]=nextLong(); in[i]=nextLong() in[i] in i nextLong() nextLong return in; in int n n public String nextLine() throws IOException {
            return br.readLine();
        } nextLine {
            return br.readLine();
        } return br.readLine(); br.readLine() br.readLine br public 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 public 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 public char nextChar() throws IOException {
            return next().charAt(0);
        } nextChar {
            return next().charAt(0);
        } return next().charAt(0); next().charAt(0) next().charAt next() next 0 public 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 public boolean ready() throws IOException {
            return br.ready();
        } ready {
            return br.ready();
        } return br.ready(); br.ready() br.ready br public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        } waitForInput {
            Thread.sleep(3000);
        } Thread.sleep(3000) Thread.sleep Thread 3000 public class Main {

    public static void main(String[] args) throws Exception {
        pw = new PrintWriter(System.out);
        sc = new MScanner(System.in);
        int n = sc.nextInt();
        int[] heights = new int[n+1];
        for(int i = 1; i <= n; ++i){
            heights[i] = sc.nextInt();
        }
        int[] dp = new int[n+1];
        heights[0] = heights[1];
        for(int pos = 2; pos <= n; ++pos){
            dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]);
        }
        pw.println(dp[n]);
        pw.flush();
    }
    static PrintWriter pw;
    static MScanner  sc;
    static class MScanner {
        StringTokenizer st;
        BufferedReader br;
        public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public MScanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public int[] intArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public long[] longArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public int[] intSortedArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public long[] longSortedArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public Integer[] IntegerArr(int n) throws IOException {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public Long[] LongArr(int n) throws IOException {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
    }
    static void shuffle(int[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
    static void shuffle(long[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
} public class Main {

    public static void main(String[] args) throws Exception {
        pw = new PrintWriter(System.out);
        sc = new MScanner(System.in);
        int n = sc.nextInt();
        int[] heights = new int[n+1];
        for(int i = 1; i <= n; ++i){
            heights[i] = sc.nextInt();
        }
        int[] dp = new int[n+1];
        heights[0] = heights[1];
        for(int pos = 2; pos <= n; ++pos){
            dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]);
        }
        pw.println(dp[n]);
        pw.flush();
    }
    static PrintWriter pw;
    static MScanner  sc;
    static class MScanner {
        StringTokenizer st;
        BufferedReader br;
        public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public MScanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public int[] intArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public long[] longArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public int[] intSortedArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public long[] longSortedArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public Integer[] IntegerArr(int n) throws IOException {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public Long[] LongArr(int n) throws IOException {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
    }
    static void shuffle(int[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
    static void shuffle(long[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
} Main
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        pw = new PrintWriter(System.out);
        sc = new MScanner(System.in);
        int n = sc.nextInt();
        int[] heights = new int[n+1];
        for(int i = 1; i <= n; ++i){
            heights[i] = sc.nextInt();
        }
        int[] dp = new int[n+1];
        heights[0] = heights[1];
        for(int pos = 2; pos <= n; ++pos){
            dp[pos] = Math.min(Math.abs(heights[pos] - heights[pos - 2]) + dp[pos - 2], Math.abs(heights[pos] - heights[pos - 1]) + dp[pos - 1]);
        }
        pw.println(dp[n]);
        pw.flush();
    }
    static PrintWriter pw;
    static MScanner  sc;
    static class MScanner {
        StringTokenizer st;
        BufferedReader br;
        public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public MScanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public int[] intArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public long[] longArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public int[] intSortedArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public long[] longSortedArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public Integer[] IntegerArr(int n) throws IOException {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public Long[] LongArr(int n) throws IOException {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
    }
    static void shuffle(int[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
    static void shuffle(long[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
}
