import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class FastReader{
	BufferedReader br;
	StringTokenizer tok;
	
	FastReader(){
		br=new BufferedReader(new InputStreamReader(System.in));
	}
	
	String next() {
		if(tok==null || (!tok.hasMoreTokens())) {
			try {
				tok = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	}
	int nextInt() {
		return Integer.parseInt(this.next());
	}
	String nextLine() {
		String s="";
		try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return s;
	}
}

public class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n=fr.nextInt();
		int arr[] = new int[n]; 
		for(int i=0; i<n; i++)
			arr[i] = fr.nextInt();
		int dp[] = new int[n];
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2; i<n; i++) 
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		System.out.println(dp[n-1]);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util class FastReader{
	BufferedReader br;
	StringTokenizer tok;
	
	FastReader(){
		br=new BufferedReader(new InputStreamReader(System.in));
	}
	
	String next() {
		if(tok==null || (!tok.hasMoreTokens())) {
			try {
				tok = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	}
	int nextInt() {
		return Integer.parseInt(this.next());
	}
	String nextLine() {
		String s="";
		try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return s;
	}
} FastReader BufferedReader br; br StringTokenizer tok; tok FastReader(){
		br=new BufferedReader(new InputStreamReader(System.in));
	} FastReader {
		br=new BufferedReader(new InputStreamReader(System.in));
	} br=new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next() {
		if(tok==null || (!tok.hasMoreTokens())) {
			try {
				tok = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	} next {
		if(tok==null || (!tok.hasMoreTokens())) {
			try {
				tok = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	} if(tok==null || (!tok.hasMoreTokens())) {
			try {
				tok = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		} tok==null || (!tok.hasMoreTokens()) tok==null tok null (!tok.hasMoreTokens()) tok.hasMoreTokens() tok.hasMoreTokens tok {
			try {
				tok = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		} try {
				tok = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			} IOException e {
				e.printStackTrace();
			} e.printStackTrace() e.printStackTrace e {
				tok = new StringTokenizer(br.readLine());
			} tok = new StringTokenizer(br.readLine()) tok new StringTokenizer(br.readLine()) return tok.nextToken(); tok.nextToken() tok.nextToken tok int nextInt() {
		return Integer.parseInt(this.next());
	} nextInt {
		return Integer.parseInt(this.next());
	} return Integer.parseInt(this.next()); Integer.parseInt(this.next()) Integer.parseInt Integer this.next() this.next this String nextLine() {
		String s="";
		try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return s;
	} nextLine {
		String s="";
		try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return s;
	} String s=""; s "" try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			s = br.readLine();
		} s = br.readLine() s br.readLine() br.readLine br return s; s public class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n=fr.nextInt();
		int arr[] = new int[n]; 
		for(int i=0; i<n; i++)
			arr[i] = fr.nextInt();
		int dp[] = new int[n];
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2; i<n; i++) 
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		System.out.println(dp[n-1]);
	}
} Main public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n=fr.nextInt();
		int arr[] = new int[n]; 
		for(int i=0; i<n; i++)
			arr[i] = fr.nextInt();
		int dp[] = new int[n];
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2; i<n; i++) 
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		System.out.println(dp[n-1]);
	} main {
		FastReader fr = new FastReader();
		int n=fr.nextInt();
		int arr[] = new int[n]; 
		for(int i=0; i<n; i++)
			arr[i] = fr.nextInt();
		int dp[] = new int[n];
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2; i<n; i++) 
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		System.out.println(dp[n-1]);
	} FastReader fr = new FastReader(); fr new FastReader() int n=fr.nextInt(); n fr.nextInt() fr.nextInt fr int arr[] = new int[n]; arr new int[n] n for(int i=0; i<n; i++)
			arr[i] = fr.nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i arr[i] = fr.nextInt(); arr[i] = fr.nextInt() arr[i] arr i fr.nextInt() fr.nextInt fr int dp[] = new int[n]; dp new int[n] n dp[1] = Math.abs(arr[1]-arr[0]) dp[1] dp 1 Math.abs(arr[1]-arr[0]) Math.abs Math arr[1]-arr[0] arr[1] arr 1 arr[0] arr 0 for(int i=2; i<n; i++) 
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2])); int i=2; int i=2; i 2 i<n i n i++ i++ i dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2])); dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2])) dp[i] dp i Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2])) Math.min Math dp[i-1]+Math.abs(arr[i]-arr[i-1]) dp[i-1] dp i-1 i 1 Math.abs(arr[i]-arr[i-1]) Math.abs Math arr[i]-arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 dp[i-2]+Math.abs(arr[i]-arr[i-2]) dp[i-2] dp i-2 i 2 Math.abs(arr[i]-arr[i-2]) Math.abs Math arr[i]-arr[i-2] arr[i] arr i arr[i-2] arr i-2 i 2 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 class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n=fr.nextInt();
		int arr[] = new int[n]; 
		for(int i=0; i<n; i++)
			arr[i] = fr.nextInt();
		int dp[] = new int[n];
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2; i<n; i++) 
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		System.out.println(dp[n-1]);
	}
} public class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n=fr.nextInt();
		int arr[] = new int[n]; 
		for(int i=0; i<n; i++)
			arr[i] = fr.nextInt();
		int dp[] = new int[n];
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2; i<n; i++) 
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		System.out.println(dp[n-1]);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class FastReader{
	BufferedReader br;
	StringTokenizer tok;
	
	FastReader(){
		br=new BufferedReader(new InputStreamReader(System.in));
	}
	
	String next() {
		if(tok==null || (!tok.hasMoreTokens())) {
			try {
				tok = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	}
	int nextInt() {
		return Integer.parseInt(this.next());
	}
	String nextLine() {
		String s="";
		try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return s;
	}
}

public class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n=fr.nextInt();
		int arr[] = new int[n]; 
		for(int i=0; i<n; i++)
			arr[i] = fr.nextInt();
		int dp[] = new int[n];
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2; i<n; i++) 
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		System.out.println(dp[n-1]);
	}
}
