// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;

const int OO = 0x3f3f3f3f;

//const long long OO = (long long) 5e18+7;

//const unsigned long long UOO = (long long) 10e18+7;

#define lp(i,a,n) for(long long i = a ; i < n ; ++i)

#define lpr(i,a,n) for(long long i = a ; i >= n ; --i)

#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)

#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)

#define eps (1e-5)

#define pb(i) push_back(i)

#define EPS 1e-9

#define sz(x) int((x).size())

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

#define ff first

#define ss second

#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl

#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl



typedef vector<int> vi ;

typedef   long long ll;

typedef   unsigned long long ull;

typedef vector<ll> vll ;

typedef pair<int,int> pii ;

typedef vector< pair<int,int> >  vpii;

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

typedef vector<vector<int> > vvi ;

typedef complex<double> point;

typedef pair<ll,ll> pll;



using namespace std;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}

ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p

ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}

ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }

ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//int i=uniform_int_distribution<int>(1,n)(rng);





int N;

vi h;

int mem[100005];



int dp(int pos){

    if(pos > N) return 1000000000;

    if(pos == N) return 0;

    if(mem[pos]!=-1) return mem[pos];

    int a = 1000000000,b = 1000000000;

    if(pos+1 <= N) a = abs(h[pos]-h[pos+1])+ dp(pos+1);

    if(pos+2 <= N) b = abs(h[pos]-h[pos+2]) + dp(pos+2);

    return mem[pos]=min(a,b);

}









int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

//    cout.tie(0);

//#ifndef ONLINE_JUDGE

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

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

//#endif



    cin >> N;

    h.resize(N);

    lp(i,0,N) cin >> h[i];

    --N;

    memset(mem,-1,sizeof mem);

    cout << dp(0);





    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;

const int OO = 0x3f3f3f3f;

//const long long OO = (long long) 5e18+7;

//const unsigned long long UOO = (long long) 10e18+7;

#define lp(i,a,n) for(long long i = a ; i < n ; ++i)

#define lpr(i,a,n) for(long long i = a ; i >= n ; --i)

#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)

#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)

#define eps (1e-5)

#define pb(i) push_back(i)

#define EPS 1e-9

#define sz(x) int((x).size())

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

#define ff first

#define ss second

#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl

#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl



typedef vector<int> vi ;

typedef   long long ll;

typedef   unsigned long long ull;

typedef vector<ll> vll ;

typedef pair<int,int> pii ;

typedef vector< pair<int,int> >  vpii;

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

typedef vector<vector<int> > vvi ;

typedef complex<double> point;

typedef pair<ll,ll> pll;



using namespace std;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}

ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p

ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}

ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }

ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//int i=uniform_int_distribution<int>(1,n)(rng);





int N;

vi h;

int mem[100005];













int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

//    cout.tie(0);

//#ifndef ONLINE_JUDGE

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

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

//#endif



    cin >> N;

    h.resize(N);

    lp(i,0,N) cin >> h[i];

    --N;

    lp(i,0,N) mem[i] = 1000000000;

    mem[N] = 0;

    lpr(i,N,1){

        if(i>0){

            mem[i-1] = min(mem[i-1],abs(h[i]-h[i-1])+mem[i]);

        }

        if(i>1){

            mem[i-2] = min(mem[i-2],abs(h[i]-h[i-2])+mem[i]);

        }



    }

    cout << mem[0];





    return 0;

}


// Fastest known solution for this problem: