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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     	int t = Integer.parseInt(br.readLine());
     	//while(t-->0) {
     	int ar[] = new int[t];
   		int dp[] = new int[t];
   		StringTokenizer st = new StringTokenizer(br.readLine());
       	for(int i =0;i<t;i++) {
       		ar[i] = Integer.parseInt(st.nextToken());
       	}
     	
       	if(t==1)
       		System.out.println(ar[0]);
       	else {
       		dp[0] = 0;
       		for(int i =1;i<t; i++) {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		}
       		System.out.println(dp[t-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 public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     	int t = Integer.parseInt(br.readLine());
     	//while(t-->0) {
     	int ar[] = new int[t];
   		int dp[] = new int[t];
   		StringTokenizer st = new StringTokenizer(br.readLine());
       	for(int i =0;i<t;i++) {
       		ar[i] = Integer.parseInt(st.nextToken());
       	}
     	
       	if(t==1)
       		System.out.println(ar[0]);
       	else {
       		dp[0] = 0;
       		for(int i =1;i<t; i++) {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		}
       		System.out.println(dp[t-1]);
       	}
	}

} Main public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     	int t = Integer.parseInt(br.readLine());
     	//while(t-->0) {
     	int ar[] = new int[t];
   		int dp[] = new int[t];
   		StringTokenizer st = new StringTokenizer(br.readLine());
       	for(int i =0;i<t;i++) {
       		ar[i] = Integer.parseInt(st.nextToken());
       	}
     	
       	if(t==1)
       		System.out.println(ar[0]);
       	else {
       		dp[0] = 0;
       		for(int i =1;i<t; i++) {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		}
       		System.out.println(dp[t-1]);
       	}
	} main {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     	int t = Integer.parseInt(br.readLine());
     	//while(t-->0) {
     	int ar[] = new int[t];
   		int dp[] = new int[t];
   		StringTokenizer st = new StringTokenizer(br.readLine());
       	for(int i =0;i<t;i++) {
       		ar[i] = Integer.parseInt(st.nextToken());
       	}
     	
       	if(t==1)
       		System.out.println(ar[0]);
       	else {
       		dp[0] = 0;
       		for(int i =1;i<t; i++) {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		}
       		System.out.println(dp[t-1]);
       	}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int t = Integer.parseInt(br.readLine()); t Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int ar[] = new int[t]; ar new int[t] t int dp[] = new int[t]; dp new int[t] t StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) for(int i =0;i<t;i++) {
       		ar[i] = Integer.parseInt(st.nextToken());
       	} int i =0; int i =0; i 0 i<t i t i++ i++ i {
       		ar[i] = Integer.parseInt(st.nextToken());
       	} {
       		ar[i] = Integer.parseInt(st.nextToken());
       	} ar[i] = Integer.parseInt(st.nextToken()) ar[i] ar i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st if(t==1)
       		System.out.println(ar[0]);
       	else {
       		dp[0] = 0;
       		for(int i =1;i<t; i++) {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		}
       		System.out.println(dp[t-1]);
       	} t==1 t 1 System.out.println(ar[0]) System.out.println System.out System System.out ar[0] ar 0 {
       		dp[0] = 0;
       		for(int i =1;i<t; i++) {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		}
       		System.out.println(dp[t-1]);
       	} dp[0] = 0 dp[0] dp 0 0 for(int i =1;i<t; i++) {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		} int i =1; int i =1; i 1 i<t i t i++ i++ i {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		} {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		} dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1])) dp[i] dp i Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1])) Math.min Math i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE i>1 i 1 dp[i-2] + Math.abs(ar[i] - ar[i-2]) dp[i-2] dp i-2 i 2 Math.abs(ar[i] - ar[i-2]) Math.abs Math ar[i] - ar[i-2] ar[i] ar i ar[i-2] ar i-2 i 2 Integer.MAX_VALUE Integer Integer.MAX_VALUE dp[i-1]+Math.abs(ar[i]-ar[i-1]) dp[i-1] dp i-1 i 1 Math.abs(ar[i]-ar[i-1]) Math.abs Math ar[i]-ar[i-1] ar[i] ar i ar[i-1] ar i-1 i 1 System.out.println(dp[t-1]) System.out.println System.out System System.out dp[t-1] dp t-1 t 1 String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     	int t = Integer.parseInt(br.readLine());
     	//while(t-->0) {
     	int ar[] = new int[t];
   		int dp[] = new int[t];
   		StringTokenizer st = new StringTokenizer(br.readLine());
       	for(int i =0;i<t;i++) {
       		ar[i] = Integer.parseInt(st.nextToken());
       	}
     	
       	if(t==1)
       		System.out.println(ar[0]);
       	else {
       		dp[0] = 0;
       		for(int i =1;i<t; i++) {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		}
       		System.out.println(dp[t-1]);
       	}
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     	int t = Integer.parseInt(br.readLine());
     	//while(t-->0) {
     	int ar[] = new int[t];
   		int dp[] = new int[t];
   		StringTokenizer st = new StringTokenizer(br.readLine());
       	for(int i =0;i<t;i++) {
       		ar[i] = Integer.parseInt(st.nextToken());
       	}
     	
       	if(t==1)
       		System.out.println(ar[0]);
       	else {
       		dp[0] = 0;
       		for(int i =1;i<t; i++) {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		}
       		System.out.println(dp[t-1]);
       	}
	}

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     	int t = Integer.parseInt(br.readLine());
     	//while(t-->0) {
     	int ar[] = new int[t];
   		int dp[] = new int[t];
   		StringTokenizer st = new StringTokenizer(br.readLine());
       	for(int i =0;i<t;i++) {
       		ar[i] = Integer.parseInt(st.nextToken());
       	}
     	
       	if(t==1)
       		System.out.println(ar[0]);
       	else {
       		dp[0] = 0;
       		for(int i =1;i<t; i++) {
       			dp[i] = Math.min(i>1 ? dp[i-2] + Math.abs(ar[i] - ar[i-2]) : Integer.MAX_VALUE, dp[i-1]+Math.abs(ar[i]-ar[i-1]));
       		}
       		System.out.println(dp[t-1]);
       	}
	}

}
