#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> d(n,0),h(n);
  for(auto& i:h)cin>>i;
  for(int i=1;i<n;++i)d[i]=min(d[i-1]+abs(h[i]-h[i-1]),i>1?d[i-2]+abs(h[i]-h[i-2]):INT_MAX);
  cout<<d[n-1];
}