#include <bits/stdc++.h>
using namespace std;
unsigned long long int n, h, arr[100010], best, f[100010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	f[n]=0;
	for(int i=n-1;i>0;i--){
		best=min(f[i-1]+abs(arr[i-1]-arr[i]), f[i-2]+abs(arr[i-2]+arr[i]));
			
	}
	cout << best << endl;
}