#include<iostream>
#include<cmath>
using namespace std;
int dp[100005];
int h[100005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>h[i];
	dp[1]=abs(h[1]-h[0]);
	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-1]<<endl;
	return 0;
}
