
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    public static void main(String[] args) {
        new Main().run();
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int found(int[][] all, int m, int x, int y){
        for(int i=0;i<m;i++)
            if(all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y)
                continue;
            else
                return i;
        return -1;
    }

    // solution
    public static int log2(int x)
    {
        return (int) (Math.log(x) / Math.log(2));
    }

    void solve() throws IOException {
        int n = readInt();
        int[] all = new int[n];
        int[] res = new int[n];
        for(int i=0;i<n;i++)
            all[i]=readInt();
        res[0]=0;
        for(int i=1;i<n;i++){
            int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1];
            int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2];
            res[i]=Math.min(cost1, cost2);
        }
        System.out.println(res[n-1]);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    public static void main(String[] args) {
        new Main().run();
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int found(int[][] all, int m, int x, int y){
        for(int i=0;i<m;i++)
            if(all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y)
                continue;
            else
                return i;
        return -1;
    }

    // solution
    public static int log2(int x)
    {
        return (int) (Math.log(x) / Math.log(2));
    }

    void solve() throws IOException {
        int n = readInt();
        int[] all = new int[n];
        int[] res = new int[n];
        for(int i=0;i<n;i++)
            all[i]=readInt();
        res[0]=0;
        for(int i=1;i<n;i++){
            int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1];
            int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2];
            res[i]=Math.min(cost1, cost2);
        }
        System.out.println(res[n-1]);
    }
} Main BufferedReader in; in PrintWriter out; out StringTokenizer tok = new StringTokenizer(""); tok new StringTokenizer("") public static void main(String[] args) {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    } run {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    } try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        } Throwable t {
            t.printStackTrace(System.err);
            System.exit(-1);
        } t.printStackTrace(System.err) t.printStackTrace t System.err System System.err System.exit(-1) System.exit System -1 1 {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } in = new BufferedReader(new InputStreamReader(System.in)) in new BufferedReader(new InputStreamReader(System.in)) out = new PrintWriter(System.out) out new PrintWriter(System.out) solve() solve in.close() in.close in out.close() out.close out String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    } readString {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    } while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        } !tok.hasMoreTokens() tok.hasMoreTokens() tok.hasMoreTokens tok {
            tok = new StringTokenizer(in.readLine());
        } tok = new StringTokenizer(in.readLine()) tok new StringTokenizer(in.readLine()) return tok.nextToken(); tok.nextToken() tok.nextToken tok int readInt() throws IOException {
        return Integer.parseInt(readString());
    } readInt {
        return Integer.parseInt(readString());
    } return Integer.parseInt(readString()); Integer.parseInt(readString()) Integer.parseInt Integer readString() readString long readLong() throws IOException {
        return Long.parseLong(readString());
    } readLong {
        return Long.parseLong(readString());
    } return Long.parseLong(readString()); Long.parseLong(readString()) Long.parseLong Long readString() readString double readDouble() throws IOException {
        return Double.parseDouble(readString());
    } readDouble {
        return Double.parseDouble(readString());
    } return Double.parseDouble(readString()); Double.parseDouble(readString()) Double.parseDouble Double readString() readString int found(int[][] all, int m, int x, int y){
        for(int i=0;i<m;i++)
            if(all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y)
                continue;
            else
                return i;
        return -1;
    } found {
        for(int i=0;i<m;i++)
            if(all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y)
                continue;
            else
                return i;
        return -1;
    } for(int i=0;i<m;i++)
            if(all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y)
                continue;
            else
                return i; int i=0; int i=0; i 0 i<m i m i++ i++ i if(all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y)
                continue;
            else
                return i; if(all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y)
                continue;
            else
                return i; all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y all[i][1] == x all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y all[i][0] == x all[i][0] all[i] all i 0 x all[i][0] == y all[i][0] all[i] all i 0 y all[i][1] == x all[i][1] all[i] all i 1 x all[i][1] == y all[i][1] all[i] all i 1 y continue; return i; i return -1; -1 1 int[][] all all int m m int x x int y y // solution
    public static int log2(int x)
    {
        return (int) (Math.log(x) / Math.log(2));
    } log2 {
        return (int) (Math.log(x) / Math.log(2));
    } return (int) (Math.log(x) / Math.log(2)); (int) (Math.log(x) / Math.log(2)) Math.log(x) Math.log Math x Math.log(2) Math.log Math 2 int x x void solve() throws IOException {
        int n = readInt();
        int[] all = new int[n];
        int[] res = new int[n];
        for(int i=0;i<n;i++)
            all[i]=readInt();
        res[0]=0;
        for(int i=1;i<n;i++){
            int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1];
            int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2];
            res[i]=Math.min(cost1, cost2);
        }
        System.out.println(res[n-1]);
    } solve {
        int n = readInt();
        int[] all = new int[n];
        int[] res = new int[n];
        for(int i=0;i<n;i++)
            all[i]=readInt();
        res[0]=0;
        for(int i=1;i<n;i++){
            int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1];
            int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2];
            res[i]=Math.min(cost1, cost2);
        }
        System.out.println(res[n-1]);
    } int n = readInt(); n readInt() readInt int[] all = new int[n]; all new int[n] n int[] res = new int[n]; res new int[n] n for(int i=0;i<n;i++)
            all[i]=readInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i all[i]=readInt(); all[i]=readInt() all[i] all i readInt() readInt res[0]=0 res[0] res 0 0 for(int i=1;i<n;i++){
            int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1];
            int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2];
            res[i]=Math.min(cost1, cost2);
        } int i=1; int i=1; i 1 i<n i n i++ i++ i {
            int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1];
            int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2];
            res[i]=Math.min(cost1, cost2);
        } {
            int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1];
            int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2];
            res[i]=Math.min(cost1, cost2);
        } int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1]; cost1 Math.abs(all[i]-all[i-1]) + res[i-1] Math.abs(all[i]-all[i-1]) Math.abs Math all[i]-all[i-1] all[i] all i all[i-1] all i-1 i 1 res[i-1] res i-1 i 1 int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2]; cost2 i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2] i==1 i 1 Integer.MAX_VALUE Integer Integer.MAX_VALUE Math.abs(all[i]-all[i-2]) + res[i-2] Math.abs(all[i]-all[i-2]) Math.abs Math all[i]-all[i-2] all[i] all i all[i-2] all i-2 i 2 res[i-2] res i-2 i 2 res[i]=Math.min(cost1, cost2) res[i] res i Math.min(cost1, cost2) Math.min Math cost1 cost2 System.out.println(res[n-1]) System.out.println System.out System System.out res[n-1] res n-1 n 1 public class Main {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    public static void main(String[] args) {
        new Main().run();
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int found(int[][] all, int m, int x, int y){
        for(int i=0;i<m;i++)
            if(all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y)
                continue;
            else
                return i;
        return -1;
    }

    // solution
    public static int log2(int x)
    {
        return (int) (Math.log(x) / Math.log(2));
    }

    void solve() throws IOException {
        int n = readInt();
        int[] all = new int[n];
        int[] res = new int[n];
        for(int i=0;i<n;i++)
            all[i]=readInt();
        res[0]=0;
        for(int i=1;i<n;i++){
            int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1];
            int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2];
            res[i]=Math.min(cost1, cost2);
        }
        System.out.println(res[n-1]);
    }
} public class Main {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    public static void main(String[] args) {
        new Main().run();
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int found(int[][] all, int m, int x, int y){
        for(int i=0;i<m;i++)
            if(all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y)
                continue;
            else
                return i;
        return -1;
    }

    // solution
    public static int log2(int x)
    {
        return (int) (Math.log(x) / Math.log(2));
    }

    void solve() throws IOException {
        int n = readInt();
        int[] all = new int[n];
        int[] res = new int[n];
        for(int i=0;i<n;i++)
            all[i]=readInt();
        res[0]=0;
        for(int i=1;i<n;i++){
            int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1];
            int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2];
            res[i]=Math.min(cost1, cost2);
        }
        System.out.println(res[n-1]);
    }
} Main

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    public static void main(String[] args) {
        new Main().run();
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int found(int[][] all, int m, int x, int y){
        for(int i=0;i<m;i++)
            if(all[i][0] == x || all[i][0] == y || all[i][1] == x || all[i][1] == y)
                continue;
            else
                return i;
        return -1;
    }

    // solution
    public static int log2(int x)
    {
        return (int) (Math.log(x) / Math.log(2));
    }

    void solve() throws IOException {
        int n = readInt();
        int[] all = new int[n];
        int[] res = new int[n];
        for(int i=0;i<n;i++)
            all[i]=readInt();
        res[0]=0;
        for(int i=1;i<n;i++){
            int cost1 = Math.abs(all[i]-all[i-1]) + res[i-1];
            int cost2 = i==1? Integer.MAX_VALUE : Math.abs(all[i]-all[i-2]) + res[i-2];
            res[i]=Math.min(cost1, cost2);
        }
        System.out.println(res[n-1]);
    }
}
