
import java.util.*;
import java.io.*;


class Main {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine().trim());
		String[] s=br.readLine().split(" ");
		int[] a=new int[n];
		int i=0;
		for(String s1:s) {
			a[i]=Integer.parseInt(s[i].trim());
			i++;
		}
		System.out.println(algo(a,n));
		
		
		

	}
	
	public static int algo(int[] a,int n) {
		int[] dp=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
//		dp[0]=0;
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-1>=0) {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			}
			if(i-2>=0) {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			}
			
		}
		return dp[n-1];
		
	}
	
	
	
	

} import java.util.*; util.* java import java.io.*; io.* java class Main {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine().trim());
		String[] s=br.readLine().split(" ");
		int[] a=new int[n];
		int i=0;
		for(String s1:s) {
			a[i]=Integer.parseInt(s[i].trim());
			i++;
		}
		System.out.println(algo(a,n));
		
		
		

	}
	
	public static int algo(int[] a,int n) {
		int[] dp=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
//		dp[0]=0;
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-1>=0) {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			}
			if(i-2>=0) {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			}
			
		}
		return dp[n-1];
		
	}
	
	
	
	

} Main public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine().trim());
		String[] s=br.readLine().split(" ");
		int[] a=new int[n];
		int i=0;
		for(String s1:s) {
			a[i]=Integer.parseInt(s[i].trim());
			i++;
		}
		System.out.println(algo(a,n));
		
		
		

	} main {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine().trim());
		String[] s=br.readLine().split(" ");
		int[] a=new int[n];
		int i=0;
		for(String s1:s) {
			a[i]=Integer.parseInt(s[i].trim());
			i++;
		}
		System.out.println(algo(a,n));
		
		
		

	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int 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 String[] s=br.readLine().split(" "); s br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] a=new int[n]; a new int[n] n int i=0; i 0 for(String s1:s) {
			a[i]=Integer.parseInt(s[i].trim());
			i++;
		} String s1 s {
			a[i]=Integer.parseInt(s[i].trim());
			i++;
		} {
			a[i]=Integer.parseInt(s[i].trim());
			i++;
		} a[i]=Integer.parseInt(s[i].trim()) a[i] a i Integer.parseInt(s[i].trim()) Integer.parseInt Integer s[i].trim() s[i].trim s[i] s i i++ i System.out.println(algo(a,n)) System.out.println System.out System System.out algo(a,n) algo a n String[] args args public static int algo(int[] a,int n) {
		int[] dp=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
//		dp[0]=0;
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-1>=0) {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			}
			if(i-2>=0) {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			}
			
		}
		return dp[n-1];
		
	} algo {
		int[] dp=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
//		dp[0]=0;
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-1>=0) {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			}
			if(i-2>=0) {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			}
			
		}
		return dp[n-1];
		
	} int[] dp=new int[n]; dp new int[n] n Arrays.fill(dp, Integer.MAX_VALUE) Arrays.fill Arrays dp Integer.MAX_VALUE Integer Integer.MAX_VALUE dp[0]=0 dp[0] dp 0 0 for(int i=1;i<n;i++) {
			if(i-1>=0) {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			}
			if(i-2>=0) {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			}
			
		} int i=1; int i=1; i 1 i<n i n i++ i++ i {
			if(i-1>=0) {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			}
			if(i-2>=0) {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			}
			
		} {
			if(i-1>=0) {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			}
			if(i-2>=0) {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			}
			
		} if(i-1>=0) {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			} i-1>=0 i-1 i 1 0 {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			} int x=dp[i-1]+Math.abs(a[i]-a[i-1]); x dp[i-1]+Math.abs(a[i]-a[i-1]) dp[i-1] dp i-1 i 1 Math.abs(a[i]-a[i-1]) Math.abs Math a[i]-a[i-1] a[i] a i a[i-1] a i-1 i 1 dp[i]=Math.min(dp[i],x) dp[i] dp i Math.min(dp[i],x) Math.min Math dp[i] dp i x if(i-2>=0) {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			} i-2>=0 i-2 i 2 0 {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			} int x=dp[i-2]+Math.abs(a[i]-a[i-2]); x dp[i-2]+Math.abs(a[i]-a[i-2]) dp[i-2] dp i-2 i 2 Math.abs(a[i]-a[i-2]) Math.abs Math a[i]-a[i-2] a[i] a i a[i-2] a i-2 i 2 dp[i]=Math.min(dp[i],x) dp[i] dp i Math.min(dp[i],x) Math.min Math dp[i] dp i x return dp[n-1]; dp[n-1] dp n-1 n 1 int[] a a int n n

import java.util.*;
import java.io.*;


class Main {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine().trim());
		String[] s=br.readLine().split(" ");
		int[] a=new int[n];
		int i=0;
		for(String s1:s) {
			a[i]=Integer.parseInt(s[i].trim());
			i++;
		}
		System.out.println(algo(a,n));
		
		
		

	}
	
	public static int algo(int[] a,int n) {
		int[] dp=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
//		dp[0]=0;
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-1>=0) {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			}
			if(i-2>=0) {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			}
			
		}
		return dp[n-1];
		
	}
	
	
	
	

}
