import java.util.Scanner;

public class Main {

	public static void main(String[]args) {
		Scanner scn = new Scanner(System.in);
		int[]a=new int[scn.nextInt()];
		for(int i=0;i<a.length;i++)a[i]=scn.nextInt();
		System.out.println(solve(a));
	}
	
	public static int solve(int[]a) {
		int[]dp=new int[a.length];
		for(int i=1;i<a.length;i++) {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		}
		return dp[a.length-1];
	}
	
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[]args) {
		Scanner scn = new Scanner(System.in);
		int[]a=new int[scn.nextInt()];
		for(int i=0;i<a.length;i++)a[i]=scn.nextInt();
		System.out.println(solve(a));
	}
	
	public static int solve(int[]a) {
		int[]dp=new int[a.length];
		for(int i=1;i<a.length;i++) {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		}
		return dp[a.length-1];
	}
	
} Main public static void main(String[]args) {
		Scanner scn = new Scanner(System.in);
		int[]a=new int[scn.nextInt()];
		for(int i=0;i<a.length;i++)a[i]=scn.nextInt();
		System.out.println(solve(a));
	} main {
		Scanner scn = new Scanner(System.in);
		int[]a=new int[scn.nextInt()];
		for(int i=0;i<a.length;i++)a[i]=scn.nextInt();
		System.out.println(solve(a));
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int[]a=new int[scn.nextInt()]; a new int[scn.nextInt()] scn.nextInt() scn.nextInt scn for(int i=0;i<a.length;i++)a[i]=scn.nextInt(); int i=0; int i=0; i 0 i<a.length i a.length a a.length i++ i++ i a[i]=scn.nextInt(); a[i]=scn.nextInt() a[i] a i scn.nextInt() scn.nextInt scn System.out.println(solve(a)) System.out.println System.out System System.out solve(a) solve a String[]args args public static int solve(int[]a) {
		int[]dp=new int[a.length];
		for(int i=1;i<a.length;i++) {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		}
		return dp[a.length-1];
	} solve {
		int[]dp=new int[a.length];
		for(int i=1;i<a.length;i++) {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		}
		return dp[a.length-1];
	} int[]dp=new int[a.length]; dp new int[a.length] a.length a a.length for(int i=1;i<a.length;i++) {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		} int i=1; int i=1; i 1 i<a.length i a.length a a.length i++ i++ i {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		} {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		} int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE f1 i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE i-1>=0 i-1 i 1 0 (Math.abs(a[i]-a[i-1])+dp[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-1] dp i-1 i 1 Integer.MAX_VALUE Integer Integer.MAX_VALUE f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE; f2 i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE i-2>=0 i-2 i 2 0 (Math.abs(a[i]-a[i-2])+dp[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-2] dp i-2 i 2 Integer.MAX_VALUE Integer Integer.MAX_VALUE dp[i]=Math.min(f1, f2) dp[i] dp i Math.min(f1, f2) Math.min Math f1 f2 return dp[a.length-1]; dp[a.length-1] dp a.length-1 a.length a a.length 1 int[]a a public class Main {

	public static void main(String[]args) {
		Scanner scn = new Scanner(System.in);
		int[]a=new int[scn.nextInt()];
		for(int i=0;i<a.length;i++)a[i]=scn.nextInt();
		System.out.println(solve(a));
	}
	
	public static int solve(int[]a) {
		int[]dp=new int[a.length];
		for(int i=1;i<a.length;i++) {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		}
		return dp[a.length-1];
	}
	
} public class Main {

	public static void main(String[]args) {
		Scanner scn = new Scanner(System.in);
		int[]a=new int[scn.nextInt()];
		for(int i=0;i<a.length;i++)a[i]=scn.nextInt();
		System.out.println(solve(a));
	}
	
	public static int solve(int[]a) {
		int[]dp=new int[a.length];
		for(int i=1;i<a.length;i++) {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		}
		return dp[a.length-1];
	}
	
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[]args) {
		Scanner scn = new Scanner(System.in);
		int[]a=new int[scn.nextInt()];
		for(int i=0;i<a.length;i++)a[i]=scn.nextInt();
		System.out.println(solve(a));
	}
	
	public static int solve(int[]a) {
		int[]dp=new int[a.length];
		for(int i=1;i<a.length;i++) {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		}
		return dp[a.length-1];
	}
	
}
