// Slower C++ solution:
//

//  CPlibrary

//

//  Created by Tanmay Singh on 3/03/2020.

// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI

//  Copyright © 2020 Tanmay Singh. All rights reserved.

//#pragma GCC target ("avx2")

//#pragma GCC optimization ("O3")

//#pragma GCC optimization ("unroll-loops")

 

#include <algorithm>

#include <bitset>

#include <cassert>

#include <chrono>

#include <cmath>

#include <complex>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <ctime>

#include <deque>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <climits>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <random>

#include <ratio>

#include <set>

#include <sstream>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

 

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

#define endl "\n"

#define mod 1000000007

typedef long long int  bigint ;

typedef std::vector< int > vi;

typedef std::vector< long long int > vll;

typedef std::vector< vi > vvi;



using namespace std ;

bigint dp[100001] ;

bigint frogJump( bigint arr[] , int N ){

    if( N == 1 ){

        return 0 ;

    }

    if( dp[N] != -1 )

        return dp[N] ;

    bigint second = INT_MAX ;

    bigint first = frogJump(arr , N - 1 ) + abs( arr[N] - arr[N-1] ) ;

    if( N > 2 )

        second = frogJump(arr, N - 2 ) + abs( arr[N] - arr[N-2] ) ;

    return dp[N] = min( first , second ) ;

}

int main(){

    FAST();

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

    int N ; cin >> N ;

    bigint arr[N+1] ;

    for( int i = 1 ; i <= N ; i++ ){

        cin >> arr[i] ;

    }

    cout << frogJump(arr, N) << endl ;

    return 0 ;

}




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

//  CPlibrary

//

//  Created by Tanmay Singh on 3/03/2020.

// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI

//  Copyright © 2020 Tanmay Singh. All rights reserved.

//#pragma GCC target ("avx2")

//#pragma GCC optimization ("O3")

//#pragma GCC optimization ("unroll-loops")

 

#include <algorithm>

#include <bitset>

#include <cassert>

#include <chrono>

#include <cmath>

#include <complex>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <ctime>

#include <deque>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <climits>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <random>

#include <ratio>

#include <set>

#include <sstream>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

 

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

#define endl "\n"

#define mod 1000000007

typedef long long int  bigint ;

typedef std::vector< int > vi;

typedef std::vector< long long int > vll;

typedef std::vector< vi > vvi;



using namespace std ;

bigint dp[100001] ;

bigint frogJump( string str , int N , int D ){

    for( int i = 0 ; i < N ; i++ ){

        dp[i] = INT_MAX ;

        if( str[i] == '0' )

            continue ;

            for( int j = i - D ; j < i ; j++ ){

                dp[i] = min( dp[i] , dp[j] + 1 ) ;

            }

    }

    return dp[N-1] ;

}

int main(){

    FAST();

    int N ; cin >> N ;

    int arr[N] ;

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

        cin >> arr[i] ;

    bigint dp[100001] ;

    dp[0] = 0 ;

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

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

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

    }

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

    return 0 ;

}