#include<bits/stdc++.h>
using namespace std;

int h[100000],dp[100001],n,ans;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>h[i];
	}
	dp[1]=abs(h[0]-h[1]);
	for (int i=2;i<n;i++){
		dp[i]=min((dp[i-2]+abs(h[i]-h[i-2])),(dp[i-1]+abs(h[i]-h[i-1])));
	}
	cout<<dp[n-1]<<"\n";
}