#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;++i){
    cin>>h[i];
  }
  int x=abs(h[n-1]-h[n-2]),y=0;
  for(int i=n-3;i>=0;--i){
    int t=min(x+abs(h[i]-h[i+1]),y +abs(h[i]-h[i+2]));
    y=x;
    x=t;
  }
  cout << x << "\n";
}
