// Slower C++ solution:
#include <bits/stdc++.h>

#define F first

#define S second

#define T second.first

#define C second.second

#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<int,pair<int,int>> piii;



const int N= 1e5+5, L = 14, OO = 0x3f3f3f3f;

const ll M=10 ;

const double ESP = 1e-8;



int n;

int A[N], dp[N];

int main(){

    FIO

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    cin>>n;

    for(int i=0; i<n; i++)cin>>A[i];

    memset(dp, OO, sizeof dp);

    dp[0] = 0;

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

        if(i+1<n){

            dp[i+1] = min(dp[i+1], dp[i] + abs(A[i]-A[i+1]));

        }

        if(i+2<n){

            dp[i+2] = min(dp[i+2], dp[i] + abs(A[i]- A[i+2]));

        }

    }

    cout<<dp[n-1];



}


// Faster C++ solution for the same problem (measured speedup: 1.4130285790528194x):
#include<bits/stdc++.h>

using namespace std;

typedef		long long       ll;

typedef         long double      dl;

typedef     unsigned long long  ull;

#define		pb              push_back

#define		PB              pop_back

#define		nn              "\n"

#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)

#define		all(p)          p.begin(),p.end()

#define		zz(v)           (ll)v.size()

#define		ss              ' '

#define	       MEM(a,b)         memset(a,(b),sizeof(a))

#define	       CLR(p)           memset(p,0,sizeof(p))

#define f0(i,b) for(int i=0;i<(b);i++)

#define f1(i,b) for(int i=1;i<=(b);i++)

#define f2(i,a,b) for(int i=(a);i<=(b);i++)

#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))

//#define       arrsize(a)      (sizeof(a)/sizeof(*a))

#define 	S(a)            scanf("%lld",&a)

#define 	SS(a,b)         scanf("%lld %lld",&a,&b)

#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)

#define		gcd(a,b)        __gcd(a,b)

#define		lcm(a,b)        (a*b)/gcd(a,b)

#define		pi              acos(-1.0)

#define	       ff               first

#define	       sc              second

typedef        pair <int, int>   pii;

typedef       pair <ll, ll>      pll;

typedef      vector< pair <ll, ll> >      vpll;

typedef		vector<ll>      vll;

typedef		map<string,ll>      msl;

typedef		map<ll,ll>      mll;

#define yes cout << "YES\n"

#define no cout<<"NO\n"

//memset(ar,-1,sizeof(ar));

//#define sort(x) sort(x.begin(), x.end())

//sort(a,a+n,greater<ll>())

//for (auto it = mp.begin(); it != mp.end(); ++it){}

// string x(w.size(),'1');

#define MAX 1000005

#define precision(a) fixed << setprecision(a)



#define mod 1000000007



ll ar[MAX],ans[MAX];



int main()

{

 //O_O ;

   ll n;

   cin>>n;

   for(ll i=1;i<=n;i++)

    cin>>ar[i];

   ans[n]=0,

   ans[n-1]=abs(ar[n-1]-ar[n]);

   for(ll i=n-2;i>=1;i--)

   {

       ans[i]=min((abs(ar[i]-ar[i+1])+ans[i+1]),(abs(ar[i]-ar[i+2])+ans[i+2]));

      // cout<<<<ss<<i<<nn;

       // cout<<(abs(ar[i]-ar[i+2])+ans[i+2])<<ss<<i<<nn;



   }

  // for(ll i=1;i<=n;i++)

   // cout<<ans[i]<<ss;cout<<nn;

   cout<<ans[1]<<nn;



    return 0;

}