#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],h[n+1];
	for(int i=1;i<=n;i++)
	cin>>h[i];
	a[n]=0;
	a[n-1]=abs(h[n]-h[n-1]);
	for(int i=n-2;i>=1;i--)
	{
		a[i]=min(abs(h[i]-h[i+1])+a[i+1],abs(h[i]-h[i+2])+a[i+2]);
	}
	cout<<a[1];
	return 0;
}