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

using namespace std;



#define clr(arr,val) memset(arr,val ,sizeof arr)

//#define first f

//#define second s



typedef  long long ull;

typedef long long ll;

int const oo=(int)1e9 ;



int const SZ= (int)1e5+1;

//const ll mod=(ll)1e9+7;

int arr[SZ];

int dp[SZ];

int n;

//int mn=oo;

int solve(int i){

    

    if(i==n-1)

        return 0;

    if(i>=n)

        return oo;

    

    int &ret=dp[i];

    

    if(ret!=-1)

        return ret;

        

    int ch1=abs(arr[i]-arr[i+1])+solve(i+1);

    int ch2=abs(arr[i]-arr[i+2])+solve(i+2);

    ret=min(ch1,ch2);

    return ret;

    

}

int main() {

//    int t ;

//    cin>>t;

//    while(t--){

        cin>>n;

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

            cin>>arr[i];

        clr(dp,-1);

        cout<<solve(0)<<endl;

//    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3461608340173166x):
//                                 Alisher_2211

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>

# define  long          long long

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

# define  allr(vc)      vc.rbegin(),vc.rend()

# define  pb            push_back

# define  fi            first 

# define  se            second

# define  pi            pair <long, long>    

# define  lcm(a, b)     (a * b) / __gcd(a, b)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;

const long N = 100100;

void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}

long dp[N];

long n;

void solve(){

    cin >> n;

    vector <long> v(n + 1), d(n);

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

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

        long o1 = dp[i - 1] + abs( v[i] - v[i - 1] );

        long o2 = dp[i - 2] + abs( v[i] - v[i - 2] );

        if( i == 2 ) o2 = 1e9 + 100;

        dp[i] = min(o1, o2);

    }

    cout << dp[n];

}

int32_t main(){

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

        long T = 1;

        //cin >> T;

        while( T-- ){

            solve();

            cout<<'\n';

        }

cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";

}