import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		long maxvalue = (long) Integer.MAX_VALUE;

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		ArrayList<Long> inputList = new ArrayList<Long>();
		ArrayList<Long> dp = new ArrayList<Long>();

		sc.nextLine();

		inputList.add((long) 0);
		for (int i = 0; i < n; i++) {
			inputList.add(sc.nextLong());
		}

		dp.add(maxvalue);
		for (int i = 0; i < n; i++) {
			dp.add(maxvalue);
		}

		dp.set(1, (long) 0);
		for (int j = 1; j < n; j++) {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		}

		System.out.println(dp.get((int) n));

	}
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		long maxvalue = (long) Integer.MAX_VALUE;

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		ArrayList<Long> inputList = new ArrayList<Long>();
		ArrayList<Long> dp = new ArrayList<Long>();

		sc.nextLine();

		inputList.add((long) 0);
		for (int i = 0; i < n; i++) {
			inputList.add(sc.nextLong());
		}

		dp.add(maxvalue);
		for (int i = 0; i < n; i++) {
			dp.add(maxvalue);
		}

		dp.set(1, (long) 0);
		for (int j = 1; j < n; j++) {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		}

		System.out.println(dp.get((int) n));

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

		long maxvalue = (long) Integer.MAX_VALUE;

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		ArrayList<Long> inputList = new ArrayList<Long>();
		ArrayList<Long> dp = new ArrayList<Long>();

		sc.nextLine();

		inputList.add((long) 0);
		for (int i = 0; i < n; i++) {
			inputList.add(sc.nextLong());
		}

		dp.add(maxvalue);
		for (int i = 0; i < n; i++) {
			dp.add(maxvalue);
		}

		dp.set(1, (long) 0);
		for (int j = 1; j < n; j++) {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		}

		System.out.println(dp.get((int) n));

	} main {

		long maxvalue = (long) Integer.MAX_VALUE;

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		ArrayList<Long> inputList = new ArrayList<Long>();
		ArrayList<Long> dp = new ArrayList<Long>();

		sc.nextLine();

		inputList.add((long) 0);
		for (int i = 0; i < n; i++) {
			inputList.add(sc.nextLong());
		}

		dp.add(maxvalue);
		for (int i = 0; i < n; i++) {
			dp.add(maxvalue);
		}

		dp.set(1, (long) 0);
		for (int j = 1; j < n; j++) {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		}

		System.out.println(dp.get((int) n));

	} long maxvalue = (long) Integer.MAX_VALUE; maxvalue (long) Integer.MAX_VALUE Integer Integer.MAX_VALUE Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc ArrayList<Long> inputList = new ArrayList<Long>(); inputList new ArrayList<Long>() ArrayList<Long> dp = new ArrayList<Long>(); dp new ArrayList<Long>() sc.nextLine() sc.nextLine sc inputList.add((long) 0) inputList.add inputList (long) 0 for (int i = 0; i < n; i++) {
			inputList.add(sc.nextLong());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			inputList.add(sc.nextLong());
		} {
			inputList.add(sc.nextLong());
		} inputList.add(sc.nextLong()) inputList.add inputList sc.nextLong() sc.nextLong sc dp.add(maxvalue) dp.add dp maxvalue for (int i = 0; i < n; i++) {
			dp.add(maxvalue);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			dp.add(maxvalue);
		} {
			dp.add(maxvalue);
		} dp.add(maxvalue) dp.add dp maxvalue dp.set(1, (long) 0) dp.set dp 1 (long) 0 for (int j = 1; j < n; j++) {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		} int j = 1; int j = 1; j 1 j < n j n j++ j++ j {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		} {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		} if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			} j + 1 <= n j + 1 j 1 n {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			} dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j))) dp.set dp j + 1 j 1 Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)) Math.min Math dp.get(j + 1) dp.get dp j + 1 j 1 Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j) Math.abs(inputList.get(j) - inputList.get(j + 1)) Math.abs Math inputList.get(j) - inputList.get(j + 1) inputList.get(j) inputList.get inputList j inputList.get(j + 1) inputList.get inputList j + 1 j 1 dp.get(j) dp.get dp j if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			} j + 2 <= n j + 2 j 2 n {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			} dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j))) dp.set dp j + 2 j 2 Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)) Math.min Math dp.get(j + 2) dp.get dp j + 2 j 2 Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j) Math.abs(inputList.get(j) - inputList.get(j + 2)) Math.abs Math inputList.get(j) - inputList.get(j + 2) inputList.get(j) inputList.get inputList j inputList.get(j + 2) inputList.get inputList j + 2 j 2 dp.get(j) dp.get dp j System.out.println(dp.get((int) n)) System.out.println System.out System System.out dp.get((int) n) dp.get dp (int) n String[] args args public class Main {

	public static void main(String[] args) {

		long maxvalue = (long) Integer.MAX_VALUE;

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		ArrayList<Long> inputList = new ArrayList<Long>();
		ArrayList<Long> dp = new ArrayList<Long>();

		sc.nextLine();

		inputList.add((long) 0);
		for (int i = 0; i < n; i++) {
			inputList.add(sc.nextLong());
		}

		dp.add(maxvalue);
		for (int i = 0; i < n; i++) {
			dp.add(maxvalue);
		}

		dp.set(1, (long) 0);
		for (int j = 1; j < n; j++) {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		}

		System.out.println(dp.get((int) n));

	}
} public class Main {

	public static void main(String[] args) {

		long maxvalue = (long) Integer.MAX_VALUE;

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		ArrayList<Long> inputList = new ArrayList<Long>();
		ArrayList<Long> dp = new ArrayList<Long>();

		sc.nextLine();

		inputList.add((long) 0);
		for (int i = 0; i < n; i++) {
			inputList.add(sc.nextLong());
		}

		dp.add(maxvalue);
		for (int i = 0; i < n; i++) {
			dp.add(maxvalue);
		}

		dp.set(1, (long) 0);
		for (int j = 1; j < n; j++) {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		}

		System.out.println(dp.get((int) n));

	}
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		long maxvalue = (long) Integer.MAX_VALUE;

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		ArrayList<Long> inputList = new ArrayList<Long>();
		ArrayList<Long> dp = new ArrayList<Long>();

		sc.nextLine();

		inputList.add((long) 0);
		for (int i = 0; i < n; i++) {
			inputList.add(sc.nextLong());
		}

		dp.add(maxvalue);
		for (int i = 0; i < n; i++) {
			dp.add(maxvalue);
		}

		dp.set(1, (long) 0);
		for (int j = 1; j < n; j++) {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		}

		System.out.println(dp.get((int) n));

	}
}
