// Original C++ solution (slower):
//AUTHOR: RAVAN_2070

//PUNE INSTITUTE OF COMPUTER TECHNOLOGY

/*

    I LOVE CLARICE STARLING



     ♥LOVE♥        ♥LOVE♥

  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥

♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥

   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥

      ♥LOVE♥♥LOVE♥♥LOVE♥

         ♥LOVE♥♥LOVE♥

            ♥LOVE♥

               ♥





    EXPLAINATION BELOW->

    1)Testcase to prove why Greedy fails

      A)4

        1 7 5 11

      Greedy approach of choosing at each step one which finds to have min |hi-hj| at a point fails here

      B)6

        1 2 10 3 0 1

     Greedy of approach of always jumping from i to i+2 so that min jumps lead to min addition of differences fails for this testcase

     

    In testcase B after handrunning bottom to top i.e right to left

    You can observe

    Optimal substructure as well as Overlapping Subproblems so Definitely Dynamic Programming

    

    State is only position

    position indicates if I start from this position what is the optimal Answer

*/

#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;

typedef long long int ll;

typedef long double ld;

typedef vector<ll> vi;

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

typedef pair<ll,ll> pii;

typedef map<ll,ll> mii;

#define MOD7 1000000007

#define MOD9 1000000009

#define pi 3.1415926535

#define Test_cases ll TC;cin>>TC;while(TC--)

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

#define pb push_back

#define mp make_pair

#define F first

#define S second

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

#define rall(x) x.rbegin(), x.rend()

#define sp(x) fixed<<setprecision(x)

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

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

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

int N;

int H[100005];

ll dp[100005];//long long since sum can surpass limits of int

ll recursion(int pos)//Bottom to top approach

{

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



    if(pos+2<N)

    dp[pos]=min(abs(H[pos]-H[pos+1])+recursion(pos+1),abs(H[pos]-H[pos+2])+recursion(pos+2));

    else if(pos+1<N)

        dp[pos]=abs(H[pos]-H[pos+1])+recursion(pos+1);

        else 

        dp[pos]=0;

    

    return dp[pos];

}

void solve()

{

   memset(dp,-1,sizeof(dp));

   int i;cin>>N;

   fo(i,0,N)cin>>H[i];

   

   recursion(0);

   cout<<dp[0]<<"\n";

   

   

}

int main()

{

   fastio

   solve();

  return 0;

}

//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>

//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector

/* TIPS FOR DEBUGGING

 * Check if values are not overflowing (use long long where required)

 * Check if ranges are inclusive or not.

 * Check properly if greedy will work or not before using it.

 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being

 * 2 minutes faster will bite you in the ass if you don't make sure

 * it works on edge cases.

 * Keep adding to this list.

*/


// Optimized solution to the same problem (faster):
//AUTHOR: RAVAN_2070

//PUNE INSTITUTE OF COMPUTER TECHNOLOGY

/*

    I LOVE CLARICE STARLING



     ♥LOVE♥        ♥LOVE♥

  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥

♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥

   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥

      ♥LOVE♥♥LOVE♥♥LOVE♥

         ♥LOVE♥♥LOVE♥

            ♥LOVE♥

               ♥





    EXPLAINATION BELOW->

    1)Testcase to prove why Greedy fails

      A)4

        1 7 5 11

      Greedy approach of choosing at each step one which finds to have min |hi-hj| at a point fails here

      B)6

        1 2 10 3 0 1

     Greedy of approach of always jumping from i to i+2 so that min jumps lead to min addition of differences fails for this testcase

     

    In testcase B after handrunning bottom to top i.e right to left

    You can observe

    Optimal substructure as well as Overlapping Subproblems so Definitely Dynamic Programming

    

    State is only position

    position indicates if I start from this position what is the optimal Answer

*/

/*

 * 

 * 

 *   ITERATIVE SOLUTION

 * 

 * */

//

#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;

typedef long long int ll;

typedef long double ld;

typedef vector<ll> vi;

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

typedef pair<ll,ll> pii;

typedef map<ll,ll> mii;

#define MOD7 1000000007

#define MOD9 1000000009

#define pi 3.1415926535

#define Test_cases ll TC;cin>>TC;while(TC--)

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

#define pb push_back

#define mp make_pair

#define F first

#define S second

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

#define rall(x) x.rbegin(), x.rend()

#define sp(x) fixed<<setprecision(x)

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

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

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

int N,i;

int H[100005];

ll dp[100005];//long long since sum can surpass limits of int

void solve()

{

  cin>>N;

  fo(i,0,N)cin>>H[i];

  

  dp[N-1]=0;

  dp[N-2]=abs(H[N-1]-H[N-2]);

  for(i=N-3;i>=0;i--)

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

  

  cout<<dp[0]<<"\n";

}

int main()

{

   fastio

   solve();

  return 0;

}

//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>

//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector

/* TIPS FOR DEBUGGING

 * Check if values are not overflowing (use long long where required)

 * Check if ranges are inclusive or not.

 * Check properly if greedy will work or not before using it.

 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being

 * 2 minutes faster will bite you in the ass if you don't make sure

 * it works on edge cases.

 * Keep adding to this list.

*/


// Fastest known solution for this problem: