#include<iostream>
#include<vector>
using namespace std;
int n,minEnergy=1e9+1;
vector<int> vt;
void cal(int index,int energy){
	if(index>n-1)	return;
	else if(index==n-1){
		if(energy<minEnergy){
			minEnergy=energy;
		}
	}else{
		cal(index+1,energy+abs(vt[index]-vt[index+1]));
		cal(index+2,energy+abs(vt[index]-vt[index+1]));
	} 
} 
int main(){

	cin>>n;
	for(int i=0;i<n;++i){
		int temp;
		cin>>temp;
		vt.push_back(temp);
	}
	cal(0,0);
	printf("%d\n",minEnergy);
	return 0;
}
