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

#define fi first

#define se second

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define rrep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

#define srep(i,s,t) for(int i=(s);i<(t);++i)

#define rng(obj) (obj).begin(), (obj).end()

#define maxs(x,y) (x=max((x),(y)))

#define mins(x,y) (x=min((x),(y)))

#define limit(x,l,r) max(l,min(x,r))

#define lims(x,l,r) (x=max(l,min(x,r)))

#define isin(x,l,r) ((l) <= (x) && (x) < (r))

#define pb push_back

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

#define uni(x) x.erase(unique(rng(x)),x.end())

#define show(x) cout<<#x<<" = "<<x<<endl;

#define PQ(T) priority_queue<T,v(T),greater<T>>

#define bn(x) ((1<<x)-1)

#define dup(x,y) (((x)+(y)-1)/(y))

#define newline puts("")

#define v(T) vector<T>

#define vv(T) vector<vector<T>>

using namespace std;

using ll = long long;

using ull = unsigned long long;

using uint = unsigned int;

using P = pair<int,int>;

using vi = vector<int>;

using vvi = vector<vi>;

using vl = vector<ll>;

using vp = vector<P>;

inline int in() { int x; cin>>x; return x;}

template <class T> inline istream& operator>>(istream&i,v(T)&v)

{ rep(j,sz(v))i>>v[j];return i;}

template <class T> string join(const v(T)&v)

{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}

template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)

{ if(sz(v))o<<join(v); return o;}

template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)

{ return i>>v.fi>>v.se;}

template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)

{ return o<<v.fi<<","<<v.se;}

template <class T> inline ll suma(const v(T)& a) 

{ ll res(0); for(auto&& x:a) res += x; return res;}

const int INF = 1001001001;

const ll LINF = 1001002003004005006ll;

const double eps = 1e-10;

#define dame {puts("-1"); return 0;}

#define yn {puts("YES");}else{puts("NO");}

const int MX = 200005;

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}

//----------------------------------------------------------------

int main(int argc,char* argv[]){

    fileio

    vi dp(MX,INF);

    int n = in();

    vi h(n);

    cin>>h;

    h.pb(INF);

    h.pb(INF);

    dp[0] = 0;

    rep(i,n){

        mins(dp[i+1], dp[i]+abs(h[i]-h[i+1]));

        mins(dp[i+2], dp[i]+abs(h[i]-h[i+2]));

    }

    cout<<dp[n-1]<< endl;

}

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

using namespace std;

#define fi first

#define se second

#define pb push_back

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define rrep(i,n) for(int i = 1; i <= (n); ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

#define srep(i,s,t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(),a.end()

#define rrng(a) a.rbegin(),a.rend()

#define uni(x) x.erase(unique(rng(x)),x.end())

#define PQ(T) priority_queue<T,v(T),greater<T> >

#define dup(x,y) (((x)+(y)-1)/(y))

#define v(T) vector<T>

#define vv(T) v(v(T))

#define diup(v,a,k) distance((v).begin(),(k)+upper_bound((v).begin(),(v).end(),(a)))

#define dilo(v,a,k) distance((v).begin(),(k)+lower_bound((v).begin(),(v).end(),(a)))

using ll = int64_t;

using ull = uint64_t;

using uint = uint32_t;

using pii = pair<int,int>;

using pll = pair<ll,ll>;

using pil = pair<int,ll>;

using vi = vector<int>;

using vvi = vector<vi>;

using vl = vector<ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)

{rep(j,v.size())i>>v[j];return i;}

template<typename T>string join(const v(T)&v)

{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)

{if(v.size())o<<join(v);return o;}

template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)

{return i>>v.fi>>v.se;}

template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)

{return o<<v.fi<<","<<v.se;}

const double eps = 1e-6;

const ll LINF = 100200300400500600ll;

const int INF = 1001001001;

//--------------------------------------------------------

#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);

#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}

#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)

//--------------------------------------------------------------

template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}

template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}

const int dx[4] = {0,1,0,-1};

const int dy[4] = {-1,0,1,0};



struct D21{

  int is,js;

  D21(int isize,int jsize){

    is = isize;

    js = jsize;

  }

  int operator()(int i,int j){

    return i*js+j;

  }

};





void Main(){

  int n;

  cin>>n;

  vi h(n);

  cin>>h;

  h.pb(0);

  h.pb(0);

  vi dp(n+2,INF);

  dp[0] = 0;

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

  rep(i,n){

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

  }

  cout<<dp[n-1]<<endl;



} int main(int argc,char** argv)

{fastio; myio; myloopset Main();}


// Fastest known solution for this problem: