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

typedef long long ll;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int inf = 1e7;
const int N  = 1e5 + 5;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int n,h[N],dp[N];

int solve(int idx) {

  if(idx==n-1) return 0;

  int &ret = dp[idx];

  if(ret!=-1) return ret;

  ret = solve(idx+1) + abs(h[idx]-h[idx+1]);

  if(idx!=n-2)
    ret = min(ret,solve(idx+2) + abs(h[idx]-h[idx+2]));

  return ret;

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    for(int i=0;i<n;++i) {

      cin >> h[i];

    }

    memset(dp,-1,sizeof(dp));

    cout << solve(0) << endl;

    return 0;
}
