#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int Maxn=100000+5;
int n,h[Maxn],f[Maxn];
int main()
{	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	for(int i=2;i<=n;i++)
		f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	printf("%d\n",f[n]);
	return 0;
}