import java.util.*;
import java.io.*;
class Main {
	static int n,arr[];
	static long dp[];
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;
//		Integer.parseInt(br.readLine().trim());
		StringBuilder printans=new StringBuilder();
		while(t-->0)
		{
			n=Integer.parseInt(br.readLine().trim());
			arr=new int[n];
			int sum=0;
			StringTokenizer tok=new StringTokenizer(br.readLine()," ");
			for(int i=0;i<n;i++) {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			}
			dp=new long[n];
			memset();
			
			printans.append(call());
		    
		}
		System.out.println(printans);

	}
	static void memset() {
		
			
		
	}
	static long call() {
		for(int i=0;i<n;i++) {
			if(i<2) {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			}
			else {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
		}
		return dp[dp.length-1];
	}

} import java.util.*; util.* java import java.io.*; io.* java class Main {
	static int n,arr[];
	static long dp[];
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;
//		Integer.parseInt(br.readLine().trim());
		StringBuilder printans=new StringBuilder();
		while(t-->0)
		{
			n=Integer.parseInt(br.readLine().trim());
			arr=new int[n];
			int sum=0;
			StringTokenizer tok=new StringTokenizer(br.readLine()," ");
			for(int i=0;i<n;i++) {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			}
			dp=new long[n];
			memset();
			
			printans.append(call());
		    
		}
		System.out.println(printans);

	}
	static void memset() {
		
			
		
	}
	static long call() {
		for(int i=0;i<n;i++) {
			if(i<2) {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			}
			else {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
		}
		return dp[dp.length-1];
	}

} Main static int n n arr[]; arr static long dp[]; dp public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;
//		Integer.parseInt(br.readLine().trim());
		StringBuilder printans=new StringBuilder();
		while(t-->0)
		{
			n=Integer.parseInt(br.readLine().trim());
			arr=new int[n];
			int sum=0;
			StringTokenizer tok=new StringTokenizer(br.readLine()," ");
			for(int i=0;i<n;i++) {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			}
			dp=new long[n];
			memset();
			
			printans.append(call());
		    
		}
		System.out.println(printans);

	} main {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;
//		Integer.parseInt(br.readLine().trim());
		StringBuilder printans=new StringBuilder();
		while(t-->0)
		{
			n=Integer.parseInt(br.readLine().trim());
			arr=new int[n];
			int sum=0;
			StringTokenizer tok=new StringTokenizer(br.readLine()," ");
			for(int i=0;i<n;i++) {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			}
			dp=new long[n];
			memset();
			
			printans.append(call());
		    
		}
		System.out.println(printans);

	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int t=1; t 1 StringBuilder printans=new StringBuilder(); printans new StringBuilder() while(t-->0)
		{
			n=Integer.parseInt(br.readLine().trim());
			arr=new int[n];
			int sum=0;
			StringTokenizer tok=new StringTokenizer(br.readLine()," ");
			for(int i=0;i<n;i++) {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			}
			dp=new long[n];
			memset();
			
			printans.append(call());
		    
		} t-->0 t-- t 0 {
			n=Integer.parseInt(br.readLine().trim());
			arr=new int[n];
			int sum=0;
			StringTokenizer tok=new StringTokenizer(br.readLine()," ");
			for(int i=0;i<n;i++) {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			}
			dp=new long[n];
			memset();
			
			printans.append(call());
		    
		} n=Integer.parseInt(br.readLine().trim()) n Integer.parseInt(br.readLine().trim()) Integer.parseInt Integer br.readLine().trim() br.readLine().trim br.readLine() br.readLine br arr=new int[n] arr new int[n] n int sum=0; sum 0 StringTokenizer tok=new StringTokenizer(br.readLine()," "); tok new StringTokenizer(br.readLine()," ") for(int i=0;i<n;i++) {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			} int i=0; int i=0; i 0 i<n i n i++ i++ i {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			} {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			} arr[i]=Integer.parseInt(tok.nextToken()) arr[i] arr i Integer.parseInt(tok.nextToken()) Integer.parseInt Integer tok.nextToken() tok.nextToken tok sum+=arr[i] sum arr[i] arr i dp=new long[n] dp new long[n] n memset() memset printans.append(call()) printans.append printans call() call System.out.println(printans) System.out.println System.out System System.out printans String[] args args static void memset() {
		
			
		
	} memset {
		
			
		
	} static long call() {
		for(int i=0;i<n;i++) {
			if(i<2) {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			}
			else {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
		}
		return dp[dp.length-1];
	} call {
		for(int i=0;i<n;i++) {
			if(i<2) {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			}
			else {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
		}
		return dp[dp.length-1];
	} for(int i=0;i<n;i++) {
			if(i<2) {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			}
			else {
				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=0; int i=0; i 0 i<n i n i++ i++ i {
			if(i<2) {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			}
			else {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
		} {
			if(i<2) {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			}
			else {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
		} if(i<2) {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			}
			else {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			} i<2 i 2 {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			} dp[0]=0 dp[0] dp 0 0 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 {
				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 return dp[dp.length-1]; dp[dp.length-1] dp dp.length-1 dp.length dp dp.length 1
import java.util.*;
import java.io.*;
class Main {
	static int n,arr[];
	static long dp[];
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;
//		Integer.parseInt(br.readLine().trim());
		StringBuilder printans=new StringBuilder();
		while(t-->0)
		{
			n=Integer.parseInt(br.readLine().trim());
			arr=new int[n];
			int sum=0;
			StringTokenizer tok=new StringTokenizer(br.readLine()," ");
			for(int i=0;i<n;i++) {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			}
			dp=new long[n];
			memset();
			
			printans.append(call());
		    
		}
		System.out.println(printans);

	}
	static void memset() {
		
			
		
	}
	static long call() {
		for(int i=0;i<n;i++) {
			if(i<2) {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			}
			else {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
		}
		return dp[dp.length-1];
	}

}
