#include <iostream>
using namespace std;
const int maxn=1e5+5;
int dp[maxn];
int h[maxn];
int path[maxn];
int main()
{
   int n;
   cin>>n;
   for(int i=1;i<=n;++i){
       cin>>h[i];
   }
   dp[1]=0;
   dp[2]=abs(h[1]-h[2]);
   for(int i=3;i<=n;++i){
       if(dp[i-1]+abs(h[i]-h[i-1])>dp[i-2]+abs(h[i]-h[i-2])){
           dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
       }
       else{
           dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
       }
   }
   cout<<dp[n]<<endl;
   return 0;
}
