import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static long rec(int i,long[]dp,long[] h) {
		
		//DPの値が更新されていたら、そのままリターン
		if(dp[i] < Long.MAX_VALUE) {
			return dp[i];
		}
		
		if(i == 0) {
			return 0;
		}
		
		// i-1,i-2 それぞれ試す
		long res = Long.MAX_VALUE;
		
		res = Math.min(rec(i-1,dp,h)+Math.abs(h[i]-h[i-1]),res);
		if(i>1) res = Math.min(rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]),res); 
				
		return dp[i] = res;
		
	}

	public static void main(String[] args) {
		Scanner stdIn  = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long[] h = new long[100010];
		long[] dp = new long[100010];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		Arrays.fill(dp,Long.MAX_VALUE);
		
		
		System.out.println(rec(n-1,dp,h));
		
		
	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	static long rec(int i,long[]dp,long[] h) {
		
		//DPの値が更新されていたら、そのままリターン
		if(dp[i] < Long.MAX_VALUE) {
			return dp[i];
		}
		
		if(i == 0) {
			return 0;
		}
		
		// i-1,i-2 それぞれ試す
		long res = Long.MAX_VALUE;
		
		res = Math.min(rec(i-1,dp,h)+Math.abs(h[i]-h[i-1]),res);
		if(i>1) res = Math.min(rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]),res); 
				
		return dp[i] = res;
		
	}

	public static void main(String[] args) {
		Scanner stdIn  = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long[] h = new long[100010];
		long[] dp = new long[100010];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		Arrays.fill(dp,Long.MAX_VALUE);
		
		
		System.out.println(rec(n-1,dp,h));
		
		
	}

} Main static long rec(int i,long[]dp,long[] h) {
		
		//DPの値が更新されていたら、そのままリターン
		if(dp[i] < Long.MAX_VALUE) {
			return dp[i];
		}
		
		if(i == 0) {
			return 0;
		}
		
		// i-1,i-2 それぞれ試す
		long res = Long.MAX_VALUE;
		
		res = Math.min(rec(i-1,dp,h)+Math.abs(h[i]-h[i-1]),res);
		if(i>1) res = Math.min(rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]),res); 
				
		return dp[i] = res;
		
	} rec {
		
		//DPの値が更新されていたら、そのままリターン
		if(dp[i] < Long.MAX_VALUE) {
			return dp[i];
		}
		
		if(i == 0) {
			return 0;
		}
		
		// i-1,i-2 それぞれ試す
		long res = Long.MAX_VALUE;
		
		res = Math.min(rec(i-1,dp,h)+Math.abs(h[i]-h[i-1]),res);
		if(i>1) res = Math.min(rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]),res); 
				
		return dp[i] = res;
		
	} if(dp[i] < Long.MAX_VALUE) {
			return dp[i];
		} dp[i] < Long.MAX_VALUE dp[i] dp i Long.MAX_VALUE Long Long.MAX_VALUE {
			return dp[i];
		} return dp[i]; dp[i] dp i if(i == 0) {
			return 0;
		} i == 0 i 0 {
			return 0;
		} return 0; 0 long res = Long.MAX_VALUE; res Long.MAX_VALUE Long Long.MAX_VALUE res = Math.min(rec(i-1,dp,h)+Math.abs(h[i]-h[i-1]),res) res Math.min(rec(i-1,dp,h)+Math.abs(h[i]-h[i-1]),res) Math.min Math rec(i-1,dp,h)+Math.abs(h[i]-h[i-1]) rec(i-1,dp,h) rec i-1 i 1 dp h 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 res if(i>1) res = Math.min(rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]),res); i>1 i 1 res = Math.min(rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]),res) res Math.min(rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]),res) Math.min Math rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]) rec(i-2,dp,h) rec i-2 i 2 dp h 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 res return dp[i] = res; dp[i] = res dp[i] dp i res int i i long[]dp dp long[] h h public static void main(String[] args) {
		Scanner stdIn  = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long[] h = new long[100010];
		long[] dp = new long[100010];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		Arrays.fill(dp,Long.MAX_VALUE);
		
		
		System.out.println(rec(n-1,dp,h));
		
		
	} main {
		Scanner stdIn  = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long[] h = new long[100010];
		long[] dp = new long[100010];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		Arrays.fill(dp,Long.MAX_VALUE);
		
		
		System.out.println(rec(n-1,dp,h));
		
		
	} Scanner stdIn  = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn long[] h = new long[100010]; h new long[100010] 100010 long[] dp = new long[100010]; dp new long[100010] 100010 for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			h[i] = stdIn.nextLong();
		} {
			h[i] = stdIn.nextLong();
		} h[i] = stdIn.nextLong() h[i] h i stdIn.nextLong() stdIn.nextLong stdIn Arrays.fill(dp,Long.MAX_VALUE) Arrays.fill Arrays dp Long.MAX_VALUE Long Long.MAX_VALUE System.out.println(rec(n-1,dp,h)) System.out.println System.out System System.out rec(n-1,dp,h) rec n-1 n 1 dp h String[] args args public class Main {
	static long rec(int i,long[]dp,long[] h) {
		
		//DPの値が更新されていたら、そのままリターン
		if(dp[i] < Long.MAX_VALUE) {
			return dp[i];
		}
		
		if(i == 0) {
			return 0;
		}
		
		// i-1,i-2 それぞれ試す
		long res = Long.MAX_VALUE;
		
		res = Math.min(rec(i-1,dp,h)+Math.abs(h[i]-h[i-1]),res);
		if(i>1) res = Math.min(rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]),res); 
				
		return dp[i] = res;
		
	}

	public static void main(String[] args) {
		Scanner stdIn  = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long[] h = new long[100010];
		long[] dp = new long[100010];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		Arrays.fill(dp,Long.MAX_VALUE);
		
		
		System.out.println(rec(n-1,dp,h));
		
		
	}

} public class Main {
	static long rec(int i,long[]dp,long[] h) {
		
		//DPの値が更新されていたら、そのままリターン
		if(dp[i] < Long.MAX_VALUE) {
			return dp[i];
		}
		
		if(i == 0) {
			return 0;
		}
		
		// i-1,i-2 それぞれ試す
		long res = Long.MAX_VALUE;
		
		res = Math.min(rec(i-1,dp,h)+Math.abs(h[i]-h[i-1]),res);
		if(i>1) res = Math.min(rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]),res); 
				
		return dp[i] = res;
		
	}

	public static void main(String[] args) {
		Scanner stdIn  = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long[] h = new long[100010];
		long[] dp = new long[100010];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		Arrays.fill(dp,Long.MAX_VALUE);
		
		
		System.out.println(rec(n-1,dp,h));
		
		
	}

} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static long rec(int i,long[]dp,long[] h) {
		
		//DPの値が更新されていたら、そのままリターン
		if(dp[i] < Long.MAX_VALUE) {
			return dp[i];
		}
		
		if(i == 0) {
			return 0;
		}
		
		// i-1,i-2 それぞれ試す
		long res = Long.MAX_VALUE;
		
		res = Math.min(rec(i-1,dp,h)+Math.abs(h[i]-h[i-1]),res);
		if(i>1) res = Math.min(rec(i-2,dp,h)+Math.abs(h[i]-h[i-2]),res); 
				
		return dp[i] = res;
		
	}

	public static void main(String[] args) {
		Scanner stdIn  = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long[] h = new long[100010];
		long[] dp = new long[100010];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		Arrays.fill(dp,Long.MAX_VALUE);
		
		
		System.out.println(rec(n-1,dp,h));
		
		
	}

}
