import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Collections;
import java.util.StringTokenizer;
 
public class Main {
	
	static int N = (int)1e9 + 7;
	static int dp[];
 
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();

		int n = sc.nextInt();
		int a[] = sc.readArray(n);
		dp = new int[n+1];
		Arrays.fill(dp, N);
		dp[0] = 0;
		for(int i = 0 ; i < n ; ++i ) {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
		
	}
	
	public 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("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
 
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java import java.util.Collections; Collections java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	
	static int N = (int)1e9 + 7;
	static int dp[];
 
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();

		int n = sc.nextInt();
		int a[] = sc.readArray(n);
		dp = new int[n+1];
		Arrays.fill(dp, N);
		dp[0] = 0;
		for(int i = 0 ; i < n ; ++i ) {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
		
	}
	
	public 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("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
 
} Main static int N = (int)1e9 + 7; N (int)1e9 + 7 (int)1e9 7 static int dp[]; dp public static void main(String[] args) {
		FastScanner sc=new FastScanner();

		int n = sc.nextInt();
		int a[] = sc.readArray(n);
		dp = new int[n+1];
		Arrays.fill(dp, N);
		dp[0] = 0;
		for(int i = 0 ; i < n ; ++i ) {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
		
	} main {
		FastScanner sc=new FastScanner();

		int n = sc.nextInt();
		int a[] = sc.readArray(n);
		dp = new int[n+1];
		Arrays.fill(dp, N);
		dp[0] = 0;
		for(int i = 0 ; i < n ; ++i ) {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
		
	} FastScanner sc=new FastScanner(); sc new FastScanner() int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int a[] = sc.readArray(n); a sc.readArray(n) sc.readArray sc n dp = new int[n+1] dp new int[n+1] n+1 n 1 Arrays.fill(dp, N) Arrays.fill Arrays dp N dp[0] = 0 dp[0] dp 0 0 for(int i = 0 ; i < n ; ++i ) {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		} int i = 0 ; int i = 0 ; i 0 i < n i n ++i ++i i {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		} {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		} for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			} int j new int[]{i+1  , i+2} {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			} {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			} if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				} j < n j n {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				} dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i])) dp[j] dp j Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i])) Math.min Math dp[j] dp j dp[i] + Math.abs(a[j] - a[i]) dp[i] dp i Math.abs(a[j] - a[i]) Math.abs Math a[j] - a[i] a[j] a j a[i] a i System.out.println(dp[n-1]) System.out.println System.out System System.out dp[n-1] dp n-1 n 1 String[] args args public 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("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	} FastScanner BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st=new StringTokenizer(""); st new StringTokenizer("") public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		} next {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		} while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				} !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements 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 long nextLong() {
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long 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 public class Main {
	
	static int N = (int)1e9 + 7;
	static int dp[];
 
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();

		int n = sc.nextInt();
		int a[] = sc.readArray(n);
		dp = new int[n+1];
		Arrays.fill(dp, N);
		dp[0] = 0;
		for(int i = 0 ; i < n ; ++i ) {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
		
	}
	
	public 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("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
 
} public class Main {
	
	static int N = (int)1e9 + 7;
	static int dp[];
 
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();

		int n = sc.nextInt();
		int a[] = sc.readArray(n);
		dp = new int[n+1];
		Arrays.fill(dp, N);
		dp[0] = 0;
		for(int i = 0 ; i < n ; ++i ) {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
		
	}
	
	public 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("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
 
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Collections;
import java.util.StringTokenizer;
 
public class Main {
	
	static int N = (int)1e9 + 7;
	static int dp[];
 
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();

		int n = sc.nextInt();
		int a[] = sc.readArray(n);
		dp = new int[n+1];
		Arrays.fill(dp, N);
		dp[0] = 0;
		for(int i = 0 ; i < n ; ++i ) {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
		
	}
	
	public 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("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
 
}
