// Slower C++ solution:
/*

    AUTHOR : TANMAY SINHA

    INORMATION TECHNOLOGY

    BIT MESRA ,RANCHI

*/

#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

using namespace __gnu_pbds;

#define ld long double

#define ull unsigned long long int

#define ll long long int

#define pb(x) push_back(x)

#define eb(x) emplace_back(x)

#define mp make_pair

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

#define mod 1000000007

#define rep(j,L,R) for(j=L;j<R;j++)

#define per(i,L,R) for(i=L;i>= R;i--)

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

#define fi first

#define se second

#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)

#define DEBUG

#ifdef DEBUG

#define deb2(args...) {dbg,args; cerr<<endl;}

#else

#define deb2(args...)

#endif

struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;

#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)

#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";

typedef vector<ll> vl;

typedef vector<vl> vvl;

typedef pair<ll,ll> pl;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}

template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}

ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}

ll power1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}



ll h[100005];

ll dp[100005];

ll ans(ll n)

{

    if(n==1)

        return 0;

    if(n==2)

        return abs(h[1]-h[0]);

    if(dp[n]!=-1)

        return dp[n];

    return dp[n]= min(ans(n-1)+abs(h[n-1]-h[n-2]),ans(n-2)+abs(h[n-1]-h[n-3]));

}



int main()

{

   SPEED

   ll n,i;

   cin>>n;

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

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

    cin>>h[i];

   cout<<ans(n);

}












// Faster C++ solution for the same problem (measured speedup: 1.7936642416720698x):
/*

    AUTHOR : TANMAY SINHA

    INORMATION TECHNOLOGY

    BIT MESRA ,RANCHI

*/

#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

using namespace __gnu_pbds;

#define ld long double

#define ull unsigned long long int

#define ll long long int

#define pb(x) push_back(x)

#define eb(x) emplace_back(x)

#define mp make_pair

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

#define mod 1000000007

#define rep(j,L,R) for(j=L;j<R;j++)

#define per(i,L,R) for(i=L;i>= R;i--)

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

#define fi first

#define se second

#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)

#define DEBUG

#ifdef DEBUG

#define deb2(args...) {dbg,args; cerr<<endl;}

#else

#define deb2(args...)

#endif

struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;

#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)

#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";

typedef vector<ll> vl;

typedef vector<vl> vvl;

typedef pair<ll,ll> pl;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}

template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}

ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}

ll power1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}



ll h[100005];

int main()

{

   SPEED

   ll n,i;

   cin>>n;

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

    cin>>h[i];

   ll dp[n+1];

   dp[0]=0;

   dp[1]=abs(h[1]-h[0]);

   if(n==2)

   {

       cout<<dp[1];

       return 0;

   }

   for(i=2;i<n;i++)

   {

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

   }

   cout<<dp[n-1];

}