#include <bits/stdc++.h> using namespace std; typedef long long LL; int arr[100007]; int dp[100007]; int Solve(int idx, int cost, int n){ 	if(idx >=n)return 1e9; 	if(idx == n - 1){ //	cout<<cost<<" "<<idx<<endl; 		return cost;	 	} 	 	if(dp[idx] != -1)return dp[idx]; 	 	int ans1 = Solve(idx+1, cost + abs(arr[idx] - arr[idx+1]), n); 	int ans2 = Solve(idx+2, cost + abs(arr[idx] - arr[idx+2]), n); 	return dp[idx] = min(ans1, ans2); } int main(){ 	int n; cin>>n; 	memset(dp,-1,sizeof(dp)); 	for(int i = 0; i < n; i++)cin>>arr[i]; 		 	cout<<Solve(0,0,n)<<endl; 	return 0; }