

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

class Main {

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		FastScanner in = new FastScanner();
//		int T = in.nextInt();
//		outer: for (int tt = 0; tt < T; tt++) {
//		}
		int n = in.nextInt();
		int a[] = in.readArray(n);
		int dp[] = new int[n + 1];
		Arrays.fill(dp, -1);
		System.out.println(frog1(dp, a, n - 1));
	}

	public static int frog1(int dp[], int a[], int N) {
		if (N == 0)
			return 0;

		if (dp[N] != -1)
			return dp[N];
		int ans = 0, ans1 = Integer.MAX_VALUE, ans2 = Integer.MAX_VALUE;
		if (N - 1 >= 0) {
			ans1 = (Math.abs(a[N] - a[N - 1]) + frog1(dp, a, N - 1));
		}
		if (N - 2 >= 0) {
			ans2 = (Math.abs(a[N] - a[N - 2]) + frog1(dp, a, N - 2));
		}
		ans = Math.min(ans1, ans2);
		dp[N] = ans;
		return ans;

	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

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

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.StringTokenizer; StringTokenizer java.util class Main {

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		FastScanner in = new FastScanner();
//		int T = in.nextInt();
//		outer: for (int tt = 0; tt < T; tt++) {
//		}
		int n = in.nextInt();
		int a[] = in.readArray(n);
		int dp[] = new int[n + 1];
		Arrays.fill(dp, -1);
		System.out.println(frog1(dp, a, n - 1));
	}

	public static int frog1(int dp[], int a[], int N) {
		if (N == 0)
			return 0;

		if (dp[N] != -1)
			return dp[N];
		int ans = 0, ans1 = Integer.MAX_VALUE, ans2 = Integer.MAX_VALUE;
		if (N - 1 >= 0) {
			ans1 = (Math.abs(a[N] - a[N - 1]) + frog1(dp, a, N - 1));
		}
		if (N - 2 >= 0) {
			ans2 = (Math.abs(a[N] - a[N - 2]) + frog1(dp, a, N - 2));
		}
		ans = Math.min(ans1, ans2);
		dp[N] = ans;
		return ans;

	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

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

} Main @SuppressWarnings("unused")
	public static void main(String[] args) {
		FastScanner in = new FastScanner();
//		int T = in.nextInt();
//		outer: for (int tt = 0; tt < T; tt++) {
//		}
		int n = in.nextInt();
		int a[] = in.readArray(n);
		int dp[] = new int[n + 1];
		Arrays.fill(dp, -1);
		System.out.println(frog1(dp, a, n - 1));
	} main {
		FastScanner in = new FastScanner();
//		int T = in.nextInt();
//		outer: for (int tt = 0; tt < T; tt++) {
//		}
		int n = in.nextInt();
		int a[] = in.readArray(n);
		int dp[] = new int[n + 1];
		Arrays.fill(dp, -1);
		System.out.println(frog1(dp, a, n - 1));
	} FastScanner in = new FastScanner(); in new FastScanner() int n = in.nextInt(); n in.nextInt() in.nextInt in int a[] = in.readArray(n); a in.readArray(n) in.readArray in n int dp[] = new int[n + 1]; dp new int[n + 1] n + 1 n 1 Arrays.fill(dp, -1) Arrays.fill Arrays dp -1 1 System.out.println(frog1(dp, a, n - 1)) System.out.println System.out System System.out frog1(dp, a, n - 1) frog1 dp a n - 1 n 1 String[] args args public static int frog1(int dp[], int a[], int N) {
		if (N == 0)
			return 0;

		if (dp[N] != -1)
			return dp[N];
		int ans = 0, ans1 = Integer.MAX_VALUE, ans2 = Integer.MAX_VALUE;
		if (N - 1 >= 0) {
			ans1 = (Math.abs(a[N] - a[N - 1]) + frog1(dp, a, N - 1));
		}
		if (N - 2 >= 0) {
			ans2 = (Math.abs(a[N] - a[N - 2]) + frog1(dp, a, N - 2));
		}
		ans = Math.min(ans1, ans2);
		dp[N] = ans;
		return ans;

	} frog1 {
		if (N == 0)
			return 0;

		if (dp[N] != -1)
			return dp[N];
		int ans = 0, ans1 = Integer.MAX_VALUE, ans2 = Integer.MAX_VALUE;
		if (N - 1 >= 0) {
			ans1 = (Math.abs(a[N] - a[N - 1]) + frog1(dp, a, N - 1));
		}
		if (N - 2 >= 0) {
			ans2 = (Math.abs(a[N] - a[N - 2]) + frog1(dp, a, N - 2));
		}
		ans = Math.min(ans1, ans2);
		dp[N] = ans;
		return ans;

	} if (N == 0)
			return 0; N == 0 N 0 return 0; 0 if (dp[N] != -1)
			return dp[N]; dp[N] != -1 dp[N] dp N -1 1 return dp[N]; dp[N] dp N int ans = 0 ans 0 ans1 = Integer.MAX_VALUE ans1 Integer.MAX_VALUE Integer Integer.MAX_VALUE ans2 = Integer.MAX_VALUE; ans2 Integer.MAX_VALUE Integer Integer.MAX_VALUE if (N - 1 >= 0) {
			ans1 = (Math.abs(a[N] - a[N - 1]) + frog1(dp, a, N - 1));
		} N - 1 >= 0 N - 1 N 1 0 {
			ans1 = (Math.abs(a[N] - a[N - 1]) + frog1(dp, a, N - 1));
		} ans1 = (Math.abs(a[N] - a[N - 1]) + frog1(dp, a, N - 1)) ans1 (Math.abs(a[N] - a[N - 1]) + frog1(dp, a, N - 1)) Math.abs(a[N] - a[N - 1]) Math.abs Math a[N] - a[N - 1] a[N] a N a[N - 1] a N - 1 N 1 frog1(dp, a, N - 1) frog1 dp a N - 1 N 1 if (N - 2 >= 0) {
			ans2 = (Math.abs(a[N] - a[N - 2]) + frog1(dp, a, N - 2));
		} N - 2 >= 0 N - 2 N 2 0 {
			ans2 = (Math.abs(a[N] - a[N - 2]) + frog1(dp, a, N - 2));
		} ans2 = (Math.abs(a[N] - a[N - 2]) + frog1(dp, a, N - 2)) ans2 (Math.abs(a[N] - a[N - 2]) + frog1(dp, a, N - 2)) Math.abs(a[N] - a[N - 2]) Math.abs Math a[N] - a[N - 2] a[N] a N a[N - 2] a N - 2 N 2 frog1(dp, a, N - 2) frog1 dp a N - 2 N 2 ans = Math.min(ans1, ans2) ans Math.min(ans1, ans2) Math.min Math ans1 ans2 dp[N] = ans dp[N] dp N ans return ans; ans int dp[] dp int a[] a int N N static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	} sort {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	} ArrayList<Integer> l = new ArrayList<>(); l new ArrayList<>() for (int i : a)
			l.add(i); int i a l.add(i); l.add(i) l.add l i Collections.sort(l) Collections.sort Collections l for (int i = 0; i < a.length; i++)
			a[i] = l.get(i); int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i a[i] = l.get(i); a[i] = l.get(i) a[i] a i l.get(i) l.get l i int[] a a static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	} FastScanner BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st = new StringTokenizer(""); st new StringTokenizer("") String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		} next {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		} while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				} !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				} IOException e {
					e.printStackTrace();
				} e.printStackTrace() e.printStackTrace e {
					st = new StringTokenizer(br.readLine());
				} st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		} readArray {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		} int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++)
				a[i] = nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = nextInt(); a[i] = nextInt() a[i] a i nextInt() nextInt return a; a int n n long nextLong() {
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

class Main {

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		FastScanner in = new FastScanner();
//		int T = in.nextInt();
//		outer: for (int tt = 0; tt < T; tt++) {
//		}
		int n = in.nextInt();
		int a[] = in.readArray(n);
		int dp[] = new int[n + 1];
		Arrays.fill(dp, -1);
		System.out.println(frog1(dp, a, n - 1));
	}

	public static int frog1(int dp[], int a[], int N) {
		if (N == 0)
			return 0;

		if (dp[N] != -1)
			return dp[N];
		int ans = 0, ans1 = Integer.MAX_VALUE, ans2 = Integer.MAX_VALUE;
		if (N - 1 >= 0) {
			ans1 = (Math.abs(a[N] - a[N - 1]) + frog1(dp, a, N - 1));
		}
		if (N - 2 >= 0) {
			ans2 = (Math.abs(a[N] - a[N - 2]) + frog1(dp, a, N - 2));
		}
		ans = Math.min(ans1, ans2);
		dp[N] = ans;
		return ans;

	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

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

}