import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		}


	}


} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		}


	}


} Main public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		}


	} main {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		}


	} try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		} {


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		} Scanner scan = new Scanner(System.in) Scanner scan = new Scanner(System.in) new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int[]h = new int[N]; h new int[N] N for(int i = 0;i<N;i++)h[i] =scan.nextInt(); int i = 0; int i = 0; i 0 i<N i N i++ i++ i h[i] =scan.nextInt(); h[i] =scan.nextInt() h[i] h i scan.nextInt() scan.nextInt scan long[]dp = new long[N+2]; dp new long[N+2] N+2 N 2 for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			} int i = 1; int i = 1; i 1 i<N i N i++ i++ i {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			} {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			} if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				} i==1 i 1 {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				} int a =  Math.abs(h[i]-h[i-1]); a Math.abs(h[i]-h[i-1]) Math.abs Math h[i]-h[i-1] h[i] h i h[i-1] h i-1 i 1 dp[i] = dp[i-1]+a dp[i] dp i dp[i-1]+a dp[i-1] dp i-1 i 1 a {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				} int a =  Math.abs(h[i]-h[i-1]); a Math.abs(h[i]-h[i-1]) Math.abs Math h[i]-h[i-1] h[i] h i h[i-1] h i-1 i 1 int b =  Math.abs(h[i]-h[i-2]); b Math.abs(h[i]-h[i-2]) Math.abs Math h[i]-h[i-2] h[i] h i h[i-2] h i-2 i 2 if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				} dp[i-1]+a>dp[i-2]+b dp[i-1]+a dp[i-1] dp i-1 i 1 a dp[i-2]+b dp[i-2] dp i-2 i 2 b {
					dp[i] = dp[i-2]+b;
				} dp[i] = dp[i-2]+b dp[i] dp i dp[i-2]+b dp[i-2] dp i-2 i 2 b {
					dp[i] = dp[i-1]+a;
				} dp[i] = dp[i-1]+a dp[i] dp i dp[i-1]+a dp[i-1] dp i-1 i 1 a System.out.println(dp[N-1]) System.out.println System.out System System.out dp[N-1] dp N-1 N 1 String[]args args public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		}


	}


} public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		}


	}


} Main
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(dp[i-1]+a>dp[i-2]+b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		}


	}


}
