#include<bits/stdc++.h>
using namespace std;

int h[10005], f[10005];

int main()
{
	int n, W;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> h[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(i == 1){
			f[i] = 0;
			continue;
		}
		else if(i == 2){
			f[i] = abs(h[1] - h[2]);
		}
		f[i] = min(f[i-1] + abs(h[i] - h[i-1]), f[i-2] + abs(h[i] - h[i-2]));
	}
	cout << f[n];
	return 0;
} 