import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=scn.nextInt();
		}
		System.out.println(frog1(arr));
		
		
	}
	public static int frog1(int[] heights) {
		
		int[] dp=new int[heights.length];
		dp[0]=0;
		dp[1]=Math.abs(heights[0]-heights[1]);
		for(int vidx=2;vidx<heights.length;vidx++) {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		}
		int len=heights.length;
		return dp[len-1];
			
	}

} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=scn.nextInt();
		}
		System.out.println(frog1(arr));
		
		
	}
	public static int frog1(int[] heights) {
		
		int[] dp=new int[heights.length];
		dp[0]=0;
		dp[1]=Math.abs(heights[0]-heights[1]);
		for(int vidx=2;vidx<heights.length;vidx++) {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		}
		int len=heights.length;
		return dp[len-1];
			
	}

} Main public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=scn.nextInt();
		}
		System.out.println(frog1(arr));
		
		
	} main {
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=scn.nextInt();
		}
		System.out.println(frog1(arr));
		
		
	} Scanner scn=new Scanner(System.in); scn new Scanner(System.in) int n=scn.nextInt(); n scn.nextInt() scn.nextInt scn int[] arr=new int[n]; arr new int[n] n for(int i=0;i<n;i++) {
			arr[i]=scn.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			arr[i]=scn.nextInt();
		} {
			arr[i]=scn.nextInt();
		} arr[i]=scn.nextInt() arr[i] arr i scn.nextInt() scn.nextInt scn System.out.println(frog1(arr)) System.out.println System.out System System.out frog1(arr) frog1 arr String[] args args public static int frog1(int[] heights) {
		
		int[] dp=new int[heights.length];
		dp[0]=0;
		dp[1]=Math.abs(heights[0]-heights[1]);
		for(int vidx=2;vidx<heights.length;vidx++) {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		}
		int len=heights.length;
		return dp[len-1];
			
	} frog1 {
		
		int[] dp=new int[heights.length];
		dp[0]=0;
		dp[1]=Math.abs(heights[0]-heights[1]);
		for(int vidx=2;vidx<heights.length;vidx++) {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		}
		int len=heights.length;
		return dp[len-1];
			
	} int[] dp=new int[heights.length]; dp new int[heights.length] heights.length heights heights.length dp[0]=0 dp[0] dp 0 0 dp[1]=Math.abs(heights[0]-heights[1]) dp[1] dp 1 Math.abs(heights[0]-heights[1]) Math.abs Math heights[0]-heights[1] heights[0] heights 0 heights[1] heights 1 for(int vidx=2;vidx<heights.length;vidx++) {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		} int vidx=2; int vidx=2; vidx 2 vidx<heights.length vidx heights.length heights heights.length vidx++ vidx++ vidx {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		} {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		} dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]) dp[vidx] dp vidx Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]) Math.min Math Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1] Math.abs(heights[vidx]-heights[vidx-1]) Math.abs Math heights[vidx]-heights[vidx-1] heights[vidx] heights vidx heights[vidx-1] heights vidx-1 vidx 1 dp[vidx-1] dp vidx-1 vidx 1 Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2] Math.abs(heights[vidx]-heights[vidx-2]) Math.abs Math heights[vidx]-heights[vidx-2] heights[vidx] heights vidx heights[vidx-2] heights vidx-2 vidx 2 dp[vidx-2] dp vidx-2 vidx 2 int len=heights.length; len heights.length heights heights.length return dp[len-1]; dp[len-1] dp len-1 len 1 int[] heights heights public class Main {
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=scn.nextInt();
		}
		System.out.println(frog1(arr));
		
		
	}
	public static int frog1(int[] heights) {
		
		int[] dp=new int[heights.length];
		dp[0]=0;
		dp[1]=Math.abs(heights[0]-heights[1]);
		for(int vidx=2;vidx<heights.length;vidx++) {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		}
		int len=heights.length;
		return dp[len-1];
			
	}

} public class Main {
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=scn.nextInt();
		}
		System.out.println(frog1(arr));
		
		
	}
	public static int frog1(int[] heights) {
		
		int[] dp=new int[heights.length];
		dp[0]=0;
		dp[1]=Math.abs(heights[0]-heights[1]);
		for(int vidx=2;vidx<heights.length;vidx++) {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		}
		int len=heights.length;
		return dp[len-1];
			
	}

} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=scn.nextInt();
		}
		System.out.println(frog1(arr));
		
		
	}
	public static int frog1(int[] heights) {
		
		int[] dp=new int[heights.length];
		dp[0]=0;
		dp[1]=Math.abs(heights[0]-heights[1]);
		for(int vidx=2;vidx<heights.length;vidx++) {
		
		
		dp[vidx]=Math.min(Math.abs(heights[vidx]-heights[vidx-1])+dp[vidx-1], Math.abs(heights[vidx]-heights[vidx-2])+dp[vidx-2]);
			
		}
		int len=heights.length;
		return dp[len-1];
			
	}

}
