// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define mod 1000000009

#define ll long long

#define mp make_pair

#define pb push_back

#define ff first

#define ss second

#define set0(a) memset ((a), 0 , sizeof(a))

#define set1(a) memset((a),-1,sizeof (a))

#define pi pair<int, int>

#define ps pair<string, string>

#define pl pair<long, long>

#define pll pair<long long, long long>

#define vll vector<long long>

#define vl vector<long>

#define vi vector<int>

#define vs vector<string>

#define vps vector< ps >

#define vpi vector< pi >

#define vpl vector< pl >

#define vpll vector< pll >

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

#define tc(t,T) for(long long t=0;t<T;t++)

#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

#define meax 100007

 vll a(meax,0);

  vll b(meax,meax);

  ll sum1=0;

ll maximize(ll i,ll n,ll prev){



    if(b[i]!=meax){

        return b[i];

    }

    if(i>=n){

        return meax;

    }



    if(i==n-1){

            b[i]=0;

        return b[i];

    }

    ll d1=maximize(i+1,n,a[i]);

    ll d2=maximize(i+2,n,a[i]);

    b[i]=min(abs(a[i]-a[i+1])+d1,abs(a[i+2]-a[i])+d2);

    return b[i];





}

int main(){

    ll n;

    cin>>n;



    rep(i,0,n,1){

        cin>>a[i];

    }

    ll d=maximize(0,n,a[0]);

    cout<<d<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 2.587550973010612x):
#include <iostream>

#include <vector>

#include <cmath>

#include <set>

#include <queue>

#include <map>

#include <cstdio>

#include <cstring>

#include <string>

#include <stack>

#include <algorithm>

#include <limits.h>

#include <bits/stdc++.h>

#define fw(x) freopen("x.txt","w",stdout)

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

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

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

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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)

#define pf printf

#define sc scanf

#define ll long long

#define pii pair<int,int>

#define pll pair<ll,ll>

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

#define vii vector<int>

#define vll vector<ll>

#define vss vector<string>

#define debug(x)  cout<<#x"="<<(x)<<endl

#define pb push_back





using namespace std;





// moves



//int dx[]= {0,0,1,-1};/*4 side move*/

//int dy[]= {-1,1,0,0};/*4 side move*/

//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/

//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/

//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/

//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/





//big_mod



//ll bigmod(ll a,ll b,ll m)

//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}

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



//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}

//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}

//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}

//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}



const int mod = 1000000007;



int main()

{

    fast;

    int n;

    cin>>n;

    int arr[n];

    REP(i, n) cin>>arr[i];

    int cost[n] = {0};

    cost[1] = abs(arr[1]-arr[0]);

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

      cost[i] = min(cost[i-1]+abs(arr[i-1]-arr[i]), cost[i-2]+abs(arr[i-2]-arr[i]));

    }

    cout<<cost[n-1]<<'\n';

    return 0;

}