import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
	static PrintWriter out=new PrintWriter(System.out);
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=sc.nextArr(n);
		long dp[]=new long[n];
		dp[1]=Math.abs(arr[0]-arr[1]);
		
		for(int i=2;i<n;i++) {
			long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2];
			long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1];
			if(a<b) {
				dp[i]=a;
			}else dp[i]=b;
		}
		out.println(dp[n-1]);
		out.close();
  }
	
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}
		public BigInteger BigInteger(String s) throws IOException{
			BigInteger a=new BigInteger(s);
			return a;
		}
	}
} import java.io.*; io.* java import java.util.*; util.* java import java.math.BigInteger; BigInteger java.math public class Main {
	static PrintWriter out=new PrintWriter(System.out);
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=sc.nextArr(n);
		long dp[]=new long[n];
		dp[1]=Math.abs(arr[0]-arr[1]);
		
		for(int i=2;i<n;i++) {
			long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2];
			long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1];
			if(a<b) {
				dp[i]=a;
			}else dp[i]=b;
		}
		out.println(dp[n-1]);
		out.close();
  }
	
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}
		public BigInteger BigInteger(String s) throws IOException{
			BigInteger a=new BigInteger(s);
			return a;
		}
	}
} Main static PrintWriter out=new PrintWriter(System.out); out new PrintWriter(System.out) public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=sc.nextArr(n);
		long dp[]=new long[n];
		dp[1]=Math.abs(arr[0]-arr[1]);
		
		for(int i=2;i<n;i++) {
			long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2];
			long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1];
			if(a<b) {
				dp[i]=a;
			}else dp[i]=b;
		}
		out.println(dp[n-1]);
		out.close();
  } main {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=sc.nextArr(n);
		long dp[]=new long[n];
		dp[1]=Math.abs(arr[0]-arr[1]);
		
		for(int i=2;i<n;i++) {
			long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2];
			long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1];
			if(a<b) {
				dp[i]=a;
			}else dp[i]=b;
		}
		out.println(dp[n-1]);
		out.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int arr[]=sc.nextArr(n); arr sc.nextArr(n) sc.nextArr sc n long dp[]=new long[n]; dp new long[n] n dp[1]=Math.abs(arr[0]-arr[1]) dp[1] dp 1 Math.abs(arr[0]-arr[1]) Math.abs Math arr[0]-arr[1] arr[0] arr 0 arr[1] arr 1 for(int i=2;i<n;i++) {
			long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2];
			long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1];
			if(a<b) {
				dp[i]=a;
			}else dp[i]=b;
		} int i=2; int i=2; i 2 i<n i n i++ i++ i {
			long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2];
			long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1];
			if(a<b) {
				dp[i]=a;
			}else dp[i]=b;
		} {
			long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2];
			long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1];
			if(a<b) {
				dp[i]=a;
			}else dp[i]=b;
		} long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2]; a (long)Math.abs(arr[i-2]-arr[i])+dp[i-2] (long)Math.abs(arr[i-2]-arr[i]) Math.abs Math arr[i-2]-arr[i] arr[i-2] arr i-2 i 2 arr[i] arr i dp[i-2] dp i-2 i 2 long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1]; b (long)Math.abs(arr[i-1]-arr[i])+dp[i-1] (long)Math.abs(arr[i-1]-arr[i]) Math.abs Math arr[i-1]-arr[i] arr[i-1] arr i-1 i 1 arr[i] arr i dp[i-1] dp i-1 i 1 if(a<b) {
				dp[i]=a;
			}else dp[i]=b; a<b a b {
				dp[i]=a;
			} dp[i]=a dp[i] dp i a dp[i]=b dp[i] dp i b out.println(dp[n-1]) out.println out dp[n-1] dp n-1 n 1 out.close() out.close out String[] args args static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}
		public BigInteger BigInteger(String s) throws IOException{
			BigInteger a=new BigInteger(s);
			return a;
		}
	} Scanner StringTokenizer st; st BufferedReader br; br public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		} Scanner {
			br = new BufferedReader(new InputStreamReader(s));
		} br = new BufferedReader(new InputStreamReader(s)) br new BufferedReader(new InputStreamReader(s)) InputStream s s public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		} Scanner {
			br = new BufferedReader(new FileReader(file));
		} br = new BufferedReader(new FileReader(file)) br new BufferedReader(new FileReader(file)) String file file public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		} next {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		} while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine()); st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() throws IOException {
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() throws IOException {
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public String nextLine() throws IOException {
			return br.readLine();
		} nextLine {
			return br.readLine();
		} return br.readLine(); br.readLine() br.readLine br public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		} nextDouble {
			return Double.parseDouble(next());
		} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public boolean ready() throws IOException {
			return br.ready();
		} ready {
			return br.ready();
		} return br.ready(); br.ready() br.ready br public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		} nextArr {
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		} int arr[]=new int[n]; arr new int[n] n for(int i=0;i<n;i++)arr[i]=nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i arr[i]=nextInt(); arr[i]=nextInt() arr[i] arr i nextInt() nextInt return arr; arr int n n public BigInteger BigInteger(String s) throws IOException{
			BigInteger a=new BigInteger(s);
			return a;
		} BigInteger {
			BigInteger a=new BigInteger(s);
			return a;
		} BigInteger a=new BigInteger(s); a new BigInteger(s) return a; a String s s public class Main {
	static PrintWriter out=new PrintWriter(System.out);
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=sc.nextArr(n);
		long dp[]=new long[n];
		dp[1]=Math.abs(arr[0]-arr[1]);
		
		for(int i=2;i<n;i++) {
			long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2];
			long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1];
			if(a<b) {
				dp[i]=a;
			}else dp[i]=b;
		}
		out.println(dp[n-1]);
		out.close();
  }
	
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}
		public BigInteger BigInteger(String s) throws IOException{
			BigInteger a=new BigInteger(s);
			return a;
		}
	}
} public class Main {
	static PrintWriter out=new PrintWriter(System.out);
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=sc.nextArr(n);
		long dp[]=new long[n];
		dp[1]=Math.abs(arr[0]-arr[1]);
		
		for(int i=2;i<n;i++) {
			long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2];
			long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1];
			if(a<b) {
				dp[i]=a;
			}else dp[i]=b;
		}
		out.println(dp[n-1]);
		out.close();
  }
	
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}
		public BigInteger BigInteger(String s) throws IOException{
			BigInteger a=new BigInteger(s);
			return a;
		}
	}
} Main
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
	static PrintWriter out=new PrintWriter(System.out);
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=sc.nextArr(n);
		long dp[]=new long[n];
		dp[1]=Math.abs(arr[0]-arr[1]);
		
		for(int i=2;i<n;i++) {
			long a=(long)Math.abs(arr[i-2]-arr[i])+dp[i-2];
			long b=(long)Math.abs(arr[i-1]-arr[i])+dp[i-1];
			if(a<b) {
				dp[i]=a;
			}else dp[i]=b;
		}
		out.println(dp[n-1]);
		out.close();
  }
	
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}
		public BigInteger BigInteger(String s) throws IOException{
			BigInteger a=new BigInteger(s);
			return a;
		}
	}
}