import java.util.*;

class Main {
    public static int frog(int[] h, int n) {
    	int[] dp = new int[n];

    	for(int i = 1; i < n; i++) {
    		dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1]);
    		if(i > 1)
    			dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));
    	}

    	return dp[n-1];
    }

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);

    	int n = sc.nextInt();
    	int[] h = new int[n];
    	for(int i = 0; i < n; i++) {
    		h[i] = sc.nextInt();
    	}

    	System.out.println(frog(h, n));
    }
} import java.util.*; util.* java class Main {
    public static int frog(int[] h, int n) {
    	int[] dp = new int[n];

    	for(int i = 1; i < n; i++) {
    		dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1]);
    		if(i > 1)
    			dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));
    	}

    	return dp[n-1];
    }

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);

    	int n = sc.nextInt();
    	int[] h = new int[n];
    	for(int i = 0; i < n; i++) {
    		h[i] = sc.nextInt();
    	}

    	System.out.println(frog(h, n));
    }
} Main public static int frog(int[] h, int n) {
    	int[] dp = new int[n];

    	for(int i = 1; i < n; i++) {
    		dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1]);
    		if(i > 1)
    			dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));
    	}

    	return dp[n-1];
    } frog {
    	int[] dp = new int[n];

    	for(int i = 1; i < n; i++) {
    		dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1]);
    		if(i > 1)
    			dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));
    	}

    	return dp[n-1];
    } int[] dp = new int[n]; dp new int[n] n for(int i = 1; i < n; i++) {
    		dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1]);
    		if(i > 1)
    			dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));
    	} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
    		dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1]);
    		if(i > 1)
    			dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));
    	} {
    		dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1]);
    		if(i > 1)
    			dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));
    	} dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1]) dp[i] dp i dp[i-1] + Math.abs(h[i] - h[i-1]) dp[i-1] dp i-1 i 1 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 if(i > 1)
    			dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2])); i > 1 i 1 dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2])) dp[i] dp i Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2])) Math.min Math dp[i] dp i dp[i-2] + Math.abs(h[i] - h[i-2]) dp[i-2] dp i-2 i 2 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 return dp[n-1]; dp[n-1] dp n-1 n 1 int[] h h int n n public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);

    	int n = sc.nextInt();
    	int[] h = new int[n];
    	for(int i = 0; i < n; i++) {
    		h[i] = sc.nextInt();
    	}

    	System.out.println(frog(h, n));
    } main {
    	Scanner sc = new Scanner(System.in);

    	int n = sc.nextInt();
    	int[] h = new int[n];
    	for(int i = 0; i < n; i++) {
    		h[i] = sc.nextInt();
    	}

    	System.out.println(frog(h, n));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] h = new int[n]; h new int[n] n for(int i = 0; i < n; i++) {
    		h[i] = sc.nextInt();
    	} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
    		h[i] = sc.nextInt();
    	} {
    		h[i] = sc.nextInt();
    	} h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc System.out.println(frog(h, n)) System.out.println System.out System System.out frog(h, n) frog h n String[] args args
import java.util.*;

class Main {
    public static int frog(int[] h, int n) {
    	int[] dp = new int[n];

    	for(int i = 1; i < n; i++) {
    		dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1]);
    		if(i > 1)
    			dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));
    	}

    	return dp[n-1];
    }

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);

    	int n = sc.nextInt();
    	int[] h = new int[n];
    	for(int i = 0; i < n; i++) {
    		h[i] = sc.nextInt();
    	}

    	System.out.println(frog(h, n));
    }
}