#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=105;
int main()
{
	int dp[maxn];
	int h[maxn];
	int n;
	while(~scanf("%d",&n)){
		for(int i=1;i<=n;i++)
			scanf("%d",&h[i]);
		dp[1] = 0;
	    for(int i=2;i<=n;i++)
	    {
		if(i==2) dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
		else dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    
	}
	printf("%d\n",dp[n]);
	}
	return 0;
}
