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

using namespace std;



#define fr(i,n) _back

#define pb	push_back

#define eb	emplace_back

#define mk	make_pair

#define fi	first

#define se	second

#define endl	'\n'



typedef long long ll;

typedef pair<int,int> ii;

typedef vector<ii> vii;

const int INF = 0x3f3f3f3f;

const double PI = acos(-1.0);

const int N = 1e5 + 3;

int h[N];

int dp[N];



int main() {

    ios_base::sync_with_stdio(false);

    memset(dp, INF, sizeof dp);

    int n; cin >> n;

    for(int i = 0; i < n; i++) cin >> h[i];



    dp[0] = 0;

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

        for(int j = max(0,i-2); j < i; j++)

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



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

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3617355766215857x):
//                                 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";

}