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

public class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni();
		int[] A = nia(N);
		int[] dp = new int[N];
		Arrays.fill(dp, 1000000000);
		dp[0] = 0;
		for (int i = 0; i < N-1; i++) {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i]));
			if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i]));
		}
		out.println(dp[N-1]);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static String rl() throws IOException {
		return f.readLine();
	}

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static long nlg(StringTokenizer st) {
		return Long.parseLong(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(rl());
	}

	static long nlg() throws IOException {
		return Long.parseLong(rl());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(rl());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni();
		int[] A = nia(N);
		int[] dp = new int[N];
		Arrays.fill(dp, 1000000000);
		dp[0] = 0;
		for (int i = 0; i < N-1; i++) {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i]));
			if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i]));
		}
		out.println(dp[N-1]);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static String rl() throws IOException {
		return f.readLine();
	}

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static long nlg(StringTokenizer st) {
		return Long.parseLong(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(rl());
	}

	static long nlg() throws IOException {
		return Long.parseLong(rl());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(rl());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
} Main static BufferedReader f; f static PrintWriter out; out static StringTokenizer st; st public static void main(String[] args) throws IOException {
		setIO();

		int N = ni();
		int[] A = nia(N);
		int[] dp = new int[N];
		Arrays.fill(dp, 1000000000);
		dp[0] = 0;
		for (int i = 0; i < N-1; i++) {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i]));
			if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i]));
		}
		out.println(dp[N-1]);
		
		f.close();
		out.close();
	} main {
		setIO();

		int N = ni();
		int[] A = nia(N);
		int[] dp = new int[N];
		Arrays.fill(dp, 1000000000);
		dp[0] = 0;
		for (int i = 0; i < N-1; i++) {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i]));
			if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i]));
		}
		out.println(dp[N-1]);
		
		f.close();
		out.close();
	} setIO() setIO int N = ni(); N ni() ni int[] A = nia(N); A nia(N) nia N int[] dp = new int[N]; dp new int[N] N Arrays.fill(dp, 1000000000) Arrays.fill Arrays dp 1000000000 dp[0] = 0 dp[0] dp 0 0 for (int i = 0; i < N-1; i++) {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i]));
			if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i]));
		} int i = 0; int i = 0; i 0 i < N-1 i N-1 N 1 i++ i++ i {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i]));
			if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i]));
		} {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i]));
			if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i]));
		} dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i])) dp[i+1] dp i+1 i 1 Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i])) Math.min Math dp[i+1] dp i+1 i 1 dp[i] + Math.abs(A[i+1] - A[i]) dp[i] dp i 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 if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i])); i < N-2 i N-2 N 2 dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i])) dp[i+2] dp i+2 i 2 Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i])) Math.min Math dp[i+2] dp i+2 i 2 dp[i] + Math.abs(A[i+2] - A[i]) dp[i] dp i 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 out.println(dp[N-1]) out.println out dp[N-1] dp N-1 N 1 f.close() f.close f out.close() out.close out String[] args args static String rl() throws IOException {
		return f.readLine();
	} rl {
		return f.readLine();
	} return f.readLine(); f.readLine() f.readLine f static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	} ni {
		return Integer.parseInt(st.nextToken());
	} return Integer.parseInt(st.nextToken()); Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st StringTokenizer st st static long nlg(StringTokenizer st) {
		return Long.parseLong(st.nextToken());
	} nlg {
		return Long.parseLong(st.nextToken());
	} return Long.parseLong(st.nextToken()); Long.parseLong(st.nextToken()) Long.parseLong Long st.nextToken() st.nextToken st StringTokenizer st st static int ni() throws IOException {
		return Integer.parseInt(rl());
	} ni {
		return Integer.parseInt(rl());
	} return Integer.parseInt(rl()); Integer.parseInt(rl()) Integer.parseInt Integer rl() rl static long nlg() throws IOException {
		return Long.parseLong(rl());
	} nlg {
		return Long.parseLong(rl());
	} return Long.parseLong(rl()); Long.parseLong(rl()) Long.parseLong Long rl() rl static StringTokenizer nl() throws IOException {
		return new StringTokenizer(rl());
	} nl {
		return new StringTokenizer(rl());
	} return new StringTokenizer(rl()); new StringTokenizer(rl()) static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	} nia {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	} StringTokenizer st = nl(); st nl() nl int[] A = new int[N]; A new int[N] N for (int i = 0; i < N; i++)
			A[i] = ni(st); int i = 0; int i = 0; i 0 i < N i N i++ i++ i A[i] = ni(st); A[i] = ni(st) A[i] A i ni(st) ni st return A; A int N N static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	} setIn {
		f = new BufferedReader(new FileReader(s));
	} f = new BufferedReader(new FileReader(s)) f new BufferedReader(new FileReader(s)) String s s static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	} setOut {
		out = new PrintWriter(new FileWriter(s));
	} out = new PrintWriter(new FileWriter(s)) out new PrintWriter(new FileWriter(s)) String s s static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	} setIn {
		f = new BufferedReader(new InputStreamReader(System.in));
	} f = new BufferedReader(new InputStreamReader(System.in)) f new BufferedReader(new InputStreamReader(System.in)) static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	} setOut {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	} out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))) out new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))) static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	} setIO {
		setIn(s + ".in");
		setOut(s + ".out");
	} setIn(s + ".in") setIn s + ".in" s ".in" setOut(s + ".out") setOut s + ".out" s ".out" String s s static void setIO() {
		setIn();
		setOut();
	} setIO {
		setIn();
		setOut();
	} setIn() setIn setOut() setOut public class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni();
		int[] A = nia(N);
		int[] dp = new int[N];
		Arrays.fill(dp, 1000000000);
		dp[0] = 0;
		for (int i = 0; i < N-1; i++) {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i]));
			if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i]));
		}
		out.println(dp[N-1]);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static String rl() throws IOException {
		return f.readLine();
	}

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static long nlg(StringTokenizer st) {
		return Long.parseLong(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(rl());
	}

	static long nlg() throws IOException {
		return Long.parseLong(rl());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(rl());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni();
		int[] A = nia(N);
		int[] dp = new int[N];
		Arrays.fill(dp, 1000000000);
		dp[0] = 0;
		for (int i = 0; i < N-1; i++) {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i]));
			if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i]));
		}
		out.println(dp[N-1]);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static String rl() throws IOException {
		return f.readLine();
	}

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static long nlg(StringTokenizer st) {
		return Long.parseLong(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(rl());
	}

	static long nlg() throws IOException {
		return Long.parseLong(rl());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(rl());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
} Main
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni();
		int[] A = nia(N);
		int[] dp = new int[N];
		Arrays.fill(dp, 1000000000);
		dp[0] = 0;
		for (int i = 0; i < N-1; i++) {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(A[i+1] - A[i]));
			if (i < N-2)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(A[i+2] - A[i]));
		}
		out.println(dp[N-1]);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static String rl() throws IOException {
		return f.readLine();
	}

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static long nlg(StringTokenizer st) {
		return Long.parseLong(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(rl());
	}

	static long nlg() throws IOException {
		return Long.parseLong(rl());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(rl());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
}
