import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[] a=new int[n];
		for (int i=0;i<n;++i) a[i]=in.nextInt();
		int fromPrevious = Math.abs(a[1] - a[0]);
        int fromBeforePrevious = 0;
		for (int i=2;i<n;++i) {
          int temp = fromPrevious;
          fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2]));
          fromBeforePrevious = temp;
		}
		System.out.println(fromPrevious);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[] a=new int[n];
		for (int i=0;i<n;++i) a[i]=in.nextInt();
		int fromPrevious = Math.abs(a[1] - a[0]);
        int fromBeforePrevious = 0;
		for (int i=2;i<n;++i) {
          int temp = fromPrevious;
          fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2]));
          fromBeforePrevious = temp;
		}
		System.out.println(fromPrevious);
	}
} Main public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[] a=new int[n];
		for (int i=0;i<n;++i) a[i]=in.nextInt();
		int fromPrevious = Math.abs(a[1] - a[0]);
        int fromBeforePrevious = 0;
		for (int i=2;i<n;++i) {
          int temp = fromPrevious;
          fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2]));
          fromBeforePrevious = temp;
		}
		System.out.println(fromPrevious);
	} main {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[] a=new int[n];
		for (int i=0;i<n;++i) a[i]=in.nextInt();
		int fromPrevious = Math.abs(a[1] - a[0]);
        int fromBeforePrevious = 0;
		for (int i=2;i<n;++i) {
          int temp = fromPrevious;
          fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2]));
          fromBeforePrevious = temp;
		}
		System.out.println(fromPrevious);
	} Scanner in=new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in int[] a=new int[n]; a new int[n] n for (int i=0;i<n;++i) a[i]=in.nextInt(); int i=0; int i=0; i 0 i<n i n ++i ++i i a[i]=in.nextInt(); a[i]=in.nextInt() a[i] a i in.nextInt() in.nextInt in int fromPrevious = Math.abs(a[1] - a[0]); fromPrevious Math.abs(a[1] - a[0]) Math.abs Math a[1] - a[0] a[1] a 1 a[0] a 0 int fromBeforePrevious = 0; fromBeforePrevious 0 for (int i=2;i<n;++i) {
          int temp = fromPrevious;
          fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2]));
          fromBeforePrevious = temp;
		} int i=2; int i=2; i 2 i<n i n ++i ++i i {
          int temp = fromPrevious;
          fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2]));
          fromBeforePrevious = temp;
		} {
          int temp = fromPrevious;
          fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2]));
          fromBeforePrevious = temp;
		} int temp = fromPrevious; temp fromPrevious fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2])) fromPrevious Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2])) Math.min Math fromPrevious + Math.abs(a[i] - a[i-1]) fromPrevious 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 fromBeforePrevious + Math.abs(a[i]-a[i-2]) fromBeforePrevious 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 fromBeforePrevious = temp fromBeforePrevious temp System.out.println(fromPrevious) System.out.println System.out System System.out fromPrevious String[] args args public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[] a=new int[n];
		for (int i=0;i<n;++i) a[i]=in.nextInt();
		int fromPrevious = Math.abs(a[1] - a[0]);
        int fromBeforePrevious = 0;
		for (int i=2;i<n;++i) {
          int temp = fromPrevious;
          fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2]));
          fromBeforePrevious = temp;
		}
		System.out.println(fromPrevious);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[] a=new int[n];
		for (int i=0;i<n;++i) a[i]=in.nextInt();
		int fromPrevious = Math.abs(a[1] - a[0]);
        int fromBeforePrevious = 0;
		for (int i=2;i<n;++i) {
          int temp = fromPrevious;
          fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2]));
          fromBeforePrevious = temp;
		}
		System.out.println(fromPrevious);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[] a=new int[n];
		for (int i=0;i<n;++i) a[i]=in.nextInt();
		int fromPrevious = Math.abs(a[1] - a[0]);
        int fromBeforePrevious = 0;
		for (int i=2;i<n;++i) {
          int temp = fromPrevious;
          fromPrevious = Math.min(fromPrevious + Math.abs(a[i] - a[i-1]), 
                                  fromBeforePrevious + Math.abs(a[i]-a[i-2]));
          fromBeforePrevious = temp;
		}
		System.out.println(fromPrevious);
	}
}