import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

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

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        out.println(findTotalJumpCost(heights, 0, dp));
        out.close();
    }

    private static int findTotalJumpCost(int[] heights, int ind, int[] dp) {
        if (ind >= heights.length) {
            return 0;
        }
        if (dp[ind] != Integer.MAX_VALUE) {
            return dp[ind];
        }
        int next = findTotalJumpCost(heights, ind+1, dp);
        if (ind + 1 < heights.length) {
            dp[ind] = Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]);
        }
        int next_to_next = findTotalJumpCost(heights, ind+2, dp);
        if (ind + 2 < heights.length) {
            dp[ind] = Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]);
        }

        return dp[ind] != Integer.MAX_VALUE ? dp[ind] : 0;
    }

}

class ModScanner {

    BufferedReader br;
    StringTokenizer st;

    public ModScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStream; OutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {

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

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        out.println(findTotalJumpCost(heights, 0, dp));
        out.close();
    }

    private static int findTotalJumpCost(int[] heights, int ind, int[] dp) {
        if (ind >= heights.length) {
            return 0;
        }
        if (dp[ind] != Integer.MAX_VALUE) {
            return dp[ind];
        }
        int next = findTotalJumpCost(heights, ind+1, dp);
        if (ind + 1 < heights.length) {
            dp[ind] = Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]);
        }
        int next_to_next = findTotalJumpCost(heights, ind+2, dp);
        if (ind + 2 < heights.length) {
            dp[ind] = Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]);
        }

        return dp[ind] != Integer.MAX_VALUE ? dp[ind] : 0;
    }

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

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        out.println(findTotalJumpCost(heights, 0, dp));
        out.close();
    } main {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        out.println(findTotalJumpCost(heights, 0, dp));
        out.close();
    } ModScanner ms = new ModScanner(); ms new ModScanner() OutputStream outputStream = System.out; outputStream System.out System System.out PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) int n = ms.nextInt(); n ms.nextInt() ms.nextInt ms int[] heights = new int[n]; heights new int[n] n for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            heights[i] = ms.nextInt();
        } {
            heights[i] = ms.nextInt();
        } heights[i] = ms.nextInt() heights[i] heights i ms.nextInt() ms.nextInt ms int[] dp = new int[n]; dp new int[n] n Arrays.fill(dp, Integer.MAX_VALUE) Arrays.fill Arrays dp Integer.MAX_VALUE Integer Integer.MAX_VALUE out.println(findTotalJumpCost(heights, 0, dp)) out.println out findTotalJumpCost(heights, 0, dp) findTotalJumpCost heights 0 dp out.close() out.close out String[] args args private static int findTotalJumpCost(int[] heights, int ind, int[] dp) {
        if (ind >= heights.length) {
            return 0;
        }
        if (dp[ind] != Integer.MAX_VALUE) {
            return dp[ind];
        }
        int next = findTotalJumpCost(heights, ind+1, dp);
        if (ind + 1 < heights.length) {
            dp[ind] = Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]);
        }
        int next_to_next = findTotalJumpCost(heights, ind+2, dp);
        if (ind + 2 < heights.length) {
            dp[ind] = Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]);
        }

        return dp[ind] != Integer.MAX_VALUE ? dp[ind] : 0;
    } findTotalJumpCost {
        if (ind >= heights.length) {
            return 0;
        }
        if (dp[ind] != Integer.MAX_VALUE) {
            return dp[ind];
        }
        int next = findTotalJumpCost(heights, ind+1, dp);
        if (ind + 1 < heights.length) {
            dp[ind] = Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]);
        }
        int next_to_next = findTotalJumpCost(heights, ind+2, dp);
        if (ind + 2 < heights.length) {
            dp[ind] = Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]);
        }

        return dp[ind] != Integer.MAX_VALUE ? dp[ind] : 0;
    } if (ind >= heights.length) {
            return 0;
        } ind >= heights.length ind heights.length heights heights.length {
            return 0;
        } return 0; 0 if (dp[ind] != Integer.MAX_VALUE) {
            return dp[ind];
        } dp[ind] != Integer.MAX_VALUE dp[ind] dp ind Integer.MAX_VALUE Integer Integer.MAX_VALUE {
            return dp[ind];
        } return dp[ind]; dp[ind] dp ind int next = findTotalJumpCost(heights, ind+1, dp); next findTotalJumpCost(heights, ind+1, dp) findTotalJumpCost heights ind+1 ind 1 dp if (ind + 1 < heights.length) {
            dp[ind] = Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]);
        } ind + 1 < heights.length ind + 1 ind 1 heights.length heights heights.length {
            dp[ind] = Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]);
        } dp[ind] = Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]) dp[ind] dp ind Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]) Math.min Math next + Math.abs(heights[ind] - heights[ind+1]) next Math.abs(heights[ind] - heights[ind+1]) Math.abs Math heights[ind] - heights[ind+1] heights[ind] heights ind heights[ind+1] heights ind+1 ind 1 dp[ind] dp ind int next_to_next = findTotalJumpCost(heights, ind+2, dp); next_to_next findTotalJumpCost(heights, ind+2, dp) findTotalJumpCost heights ind+2 ind 2 dp if (ind + 2 < heights.length) {
            dp[ind] = Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]);
        } ind + 2 < heights.length ind + 2 ind 2 heights.length heights heights.length {
            dp[ind] = Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]);
        } dp[ind] = Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]) dp[ind] dp ind Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]) Math.min Math next_to_next + Math.abs(heights[ind] - heights[ind+2]) next_to_next Math.abs(heights[ind] - heights[ind+2]) Math.abs Math heights[ind] - heights[ind+2] heights[ind] heights ind heights[ind+2] heights ind+2 ind 2 dp[ind] dp ind return dp[ind] != Integer.MAX_VALUE ? dp[ind] : 0; dp[ind] != Integer.MAX_VALUE ? dp[ind] : 0 dp[ind] != Integer.MAX_VALUE dp[ind] dp ind Integer.MAX_VALUE Integer Integer.MAX_VALUE dp[ind] dp ind 0 int[] heights heights int ind ind int[] dp dp class ModScanner {

    BufferedReader br;
    StringTokenizer st;

    public ModScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

} ModScanner BufferedReader br; br StringTokenizer st; st public ModScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    } ModScanner {
        br = new BufferedReader(new InputStreamReader(System.in));
    } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    } nextToken {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    } while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
            st = new StringTokenizer(br.readLine());

        } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st String nextString() throws Exception {
        return br.readLine();
    } nextString {
        return br.readLine();
    } return br.readLine(); br.readLine() br.readLine br int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    } nextInt {
        return Integer.parseInt(nextToken());
    } return Integer.parseInt(nextToken()); Integer.parseInt(nextToken()) Integer.parseInt Integer nextToken() nextToken long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    } nextLong {
        return Long.parseLong(nextToken());
    } return Long.parseLong(nextToken()); Long.parseLong(nextToken()) Long.parseLong Long nextToken() nextToken double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    } nextDouble {
        return Double.parseDouble(nextToken());
    } return Double.parseDouble(nextToken()); Double.parseDouble(nextToken()) Double.parseDouble Double nextToken() nextToken public class Main {

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

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        out.println(findTotalJumpCost(heights, 0, dp));
        out.close();
    }

    private static int findTotalJumpCost(int[] heights, int ind, int[] dp) {
        if (ind >= heights.length) {
            return 0;
        }
        if (dp[ind] != Integer.MAX_VALUE) {
            return dp[ind];
        }
        int next = findTotalJumpCost(heights, ind+1, dp);
        if (ind + 1 < heights.length) {
            dp[ind] = Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]);
        }
        int next_to_next = findTotalJumpCost(heights, ind+2, dp);
        if (ind + 2 < heights.length) {
            dp[ind] = Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]);
        }

        return dp[ind] != Integer.MAX_VALUE ? dp[ind] : 0;
    }

} public class Main {

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

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        out.println(findTotalJumpCost(heights, 0, dp));
        out.close();
    }

    private static int findTotalJumpCost(int[] heights, int ind, int[] dp) {
        if (ind >= heights.length) {
            return 0;
        }
        if (dp[ind] != Integer.MAX_VALUE) {
            return dp[ind];
        }
        int next = findTotalJumpCost(heights, ind+1, dp);
        if (ind + 1 < heights.length) {
            dp[ind] = Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]);
        }
        int next_to_next = findTotalJumpCost(heights, ind+2, dp);
        if (ind + 2 < heights.length) {
            dp[ind] = Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]);
        }

        return dp[ind] != Integer.MAX_VALUE ? dp[ind] : 0;
    }

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

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

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        out.println(findTotalJumpCost(heights, 0, dp));
        out.close();
    }

    private static int findTotalJumpCost(int[] heights, int ind, int[] dp) {
        if (ind >= heights.length) {
            return 0;
        }
        if (dp[ind] != Integer.MAX_VALUE) {
            return dp[ind];
        }
        int next = findTotalJumpCost(heights, ind+1, dp);
        if (ind + 1 < heights.length) {
            dp[ind] = Math.min(next + Math.abs(heights[ind] - heights[ind+1]), dp[ind]);
        }
        int next_to_next = findTotalJumpCost(heights, ind+2, dp);
        if (ind + 2 < heights.length) {
            dp[ind] = Math.min(next_to_next + Math.abs(heights[ind] - heights[ind+2]), dp[ind]);
        }

        return dp[ind] != Integer.MAX_VALUE ? dp[ind] : 0;
    }

}

class ModScanner {

    BufferedReader br;
    StringTokenizer st;

    public ModScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

}
