// Slower C++ solution:
// Created by ahmed_drawy on 10/09/19.

///dp educational contest atcoder - vjudge

#include <bits/stdc++.h>

#include <string.h>

#pragma clang diagnostic push

#pragma ide diagnostic ignored "OCUnusedMacroInspection"

using namespace std;

#define lp(i,start , end)       for(int i = start ; i<end ; ++i)

#define lllp(i,start , end)       for(ll i = start ; i<end ; ++i)

#define inN(arr ,  n) for(int i = 0 ; i< n ; ++i)  cin>>arr[i];

#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)

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

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

#define clr(v,d)                memset(v , d , sizeof(v))

#define inf 0x3f3f3f3f

//#define dbg (v)    for(auto it : v)cout<<it<<' ';

typedef long long               ll;

typedef vector<int>             vi;

typedef vector  <ll>            vll;

typedef vector<vector<int> >    adj;

typedef pair<int ,int>          pii;

const double EPS =1e-7;

const int OO = 1e6;

#define endl '\n'

#define cint(c) (int)c -'0';

#define itc(c) (char)c +'A';

bool sortpair( const pair<int , int> & x, const pair<int , int> & y){

    return  x.first != y.first ? x.first < y.first : x.second > y.second ;

}

int dcomp(double x , double y){

    return fabs(x-y) <= EPS? 0: x>y?1:-1;

}



void smile() {

    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

#ifndef ONLINE_JUDGE

//    freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);

//    freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);

#endif

}

#define fastin smile()



int n ;

const int N = 1e5 +3;

ll dp[N];

int h[N];

//ll solve(int indx , int state){

//    if(indx == n-1 )return 0 ;

//    ll &ret = dp[indx  ] [ state];

//    if(~ret )

//        return ret;

//    ret=  INT_MAX;

//    for (int i = 1; i <=2 && i+indx < n ; ++i) {

//        ret = min(ret , abs(h[indx]  - h[indx+ i])+solve(indx + i , i ));

//    }

//    return ret ;

//}

int main() {

    fastin;

    cin >> n;

    inN(h,  n );

    clr(dp , 0);

    for (int j = 1; j <n ; ++j) {

        if(j>=2){

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

        }

        else if(j ==1){

            dp[j] = abs(h[j] - h[j-1])+dp[j-1];

        }

    }

    cout << dp[n-1];

//

//    clr(dp , -1);

//    cout << solve(0, 1)<<endl;

}

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

using namespace std;

typedef vector<int> vi;

typedef vector<long long> vll;

typedef pair<int,int> pii;

typedef vector< pii > vii;



#define ll          long long

#define ff          first

#define ss          second

#define pb          push_back

#define mkp         make_pair

#define sz          size()



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

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

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

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

#define pi          2*acos(0.0)

#define End         return 0;

#define nl endl



#define scan1(a)    scanf("%d",&a)

#define scan2(a,b)  scanf("%d %d",&a,&b)

#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)

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

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

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



#define print1(a)    printf("%d",a)

#define print2(a,b)  printf("%d %d",a,b)

#define print3(a,b,c)  printf("%d %d %d",a,b,c)

#define printl(a)    printf("%lld",a)

#define printll(a,b) printf("%lld %lld",a,b)

#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)



#define MAXN        100000007

#define INF 0x3f3f3f3f

int main()

{

   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   int n;

   cin>>n;

   vll v(n+3),vv(n+3);

   for(int i=1;i<=n;i++) cin>>v[i];



   vv[1]=0;vv[2]=abs(v[2]-v[1]);

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

    vv[i]=min(vv[i-1]+abs(v[i]-v[i-1]), vv[i-2]+abs(v[i]-v[i-2]));

   }

   cout<<vv[n]<<endl;

   return 0;

}