#include <bits/stdc++.h>
 
using namespace std;
 
#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'
 
signed main () {
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
  int n;
 
  cin >> n;
 
  vector<int> dp(n + 1);
  vector<int> arr(n + 1);
 
  for(int i = 1; i <= n; i++) {
  	cin >> arr[i];
  }
 
  dp[2] = abs(arr[2] - arr[1]);
  for(int i = 3; i <= n; i++) {
  	dp[i] = min(abs(arr[i] - arr[i - 2]) + dp[i - 2], abs(arr[i] - arr[i - 1]) + dp[i - 1]);
  }
 
  cout << dp[n] << endl;
}