#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int h[100055],dp[100055];
const int inf = 0x3f3f3f;
int main()
{
	int n;
	cin>>n;
	h[1]=inf;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=2;i<=n;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n]<<endl;
	return 0;
} 