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