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



using namespace std;



const int N = 1e5; // Maximum stones as per problem



int n, stones[N];



int memo[N]; // Memoization Table



int jumps(int ind) {

    if (ind == (n - 1)) return 0; // If we are last stone, then the answer will be 0.

    if (ind >= n) return INT_MAX; // Checking the boundary condition





    // If you are done with the whole function, then only read

    // Since we stored the minimum cost for a stone, now we will use the stored cost

    // We are initializing the table to -1, if the value stored is not -1, then we have calculated the minimum cost

    // So just return that cost

    if (memo[ind] != -1) return memo[ind]; // If reading for first time, then ignore this line



    // Calculate the cost for jumping to next stone (ind + 1) and recursively doing it for next stone

    int oneJump = abs(stones[ind] - stones[ind + 1]) + jumps(ind + 1);



    // Initializing the twoJumps because there can be a case in which there can be only one stone.

    int twoJumps = INT_MAX;



    // Checking if there are more than 2 stones

    if (ind + 2 < n) {

        // Calculate the cost for jumping to next to next stone (ind + 2) and recursively doing it for next to next stone

        twoJumps = abs(stones[ind] - stones[ind + 2]) + jumps(ind + 2);

    }



    // Storing the minimum cost in the memoization table and returning the minimum cost

    // After this,  go to the ignored line.

    return memo[ind] = min(oneJump, twoJumps);

}





int main() {

    // Initializing the memoization table to -1

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



    cin >> n;

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

        cin >> stones[i];

    }



    // We will start from first stone

    cout << jumps(0) << endl;



    return 0;

}

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

}