//***************************************************************************************************||
//**********************~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*************************************||
//******************||||      AUTHOR: GUNJAN KUMAR BISWAS       ||||*********************************||
//******************||||      INSTITUTION : JGEC               ||||*********************************||
//******************||||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~||||*********************************||
//***************************************************************************************************||
// Date : 19.04.20


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;



#define f(i,a,b)        for(ll i=a;i<b;i++)
#define f0(i,n)         f(i,0,n)
#define fr(i,a,b)       for(ll i=a;i>=b;i--)
#define for1(i,n)       for(ll i=1;i<=n;i++)
#define pb              push_back
#define tc(t)           int t;cin >>t;while(t--)
#define lol             std::ios::sync_with_stdio(false); cin.tie(NULL);
#define endl            "\n"
#define mp              make_pair
#define ss              second
#define ff              first
#define ll              long long
#define int             long long
#define pii             pair< int,int >
#define pll             pair< ll,ll >
#define sz(a)           a.size()
#define inf             (1000*1000*1000+5)
#define all(a)          a.begin(),a.end()
#define arr(a,n)        int a[n];f0(i, n) cin >> a[i];
#define ini(a,n)        memset(a,n,sizeof(a))
#define printArr(a,n)   f0(i,n) cout<<a[i]<<" ";
#define in              cin>>
#define rr              return 0;
#define vint            vector< int >
#define l_b             lower_bound
#define u_b             upper_bound
#define mod             1000000007
#define pi              3.141592653589793238
#define fmap(m)         for(auto i=m.begin();i!=m.end();i++)
#define deb(x)          cout<< #x <<"=" <<x<<endl;
#define deb2(x,y)       cout<<#x<<"="<<x <<"," <<#y<<"="<<y<<endl;
void input_File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}





///////////// FUNCTIONS//////////


bool isPrime(ll n)          //checks for prime
{
    if (n <= 1)
        return false;
    for (ll i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}


ll sumofdigits(ll n)        //returns sum of digit of a no.
{
    ll c = 0;
    while (n > 0)
    {
        c++;
        n /= 10;
    }
    return c;
}


int MaxSubArraySumReturn(int a[], int  n)  //negative thakle o kaaj korbe in O(n)
{

    int sum = 0, best = 0;
    f0(i, n)
    {
        sum = max(a[i], a[i] + sum);
        best = max(best, sum);
    }
    return best;

}




int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}


int nCr(int n, int r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

bool sortinrev(const pair<int, int> &a,
               const pair<int, int> &b)
{
    return (a.first > b.first);
}

int setBitCount(int n)   //Brian Kerinigham algo.... time complexity::O(no of set bits)
{
    int ans = 0;
    while (n)
        n &= n - 1   ,  ans++;
    return ans;
}


int power(int a, int b) //a^b korte hobe   (binary exponentiation)
{
    int result = 1;
    while (b)
    {
        if (b & 1)
        {
            result *= a;
            b--;
        }
        else
        {
            a *= a;
            b >>= 1;
        }
    }
    return result;
}


//*************************************************************************************************//
//*************************************************************************************************//
//*************************************************************************************************//





//***//solver function//***
int n;
int a[100001];
int dp[100001] ;
int frogA(int ind)
{
    if (ind >= n) return INT_MAX;
    if (ind == n - 1)  return 0;
    if (dp[ind] != -1)     return dp[ind];

    int left = abs(a[ind] - a[ind + 1]) + frogA(ind + 1);


    int right = abs(a[ind] - a[ind + 2]) + frogA(ind + 2);
    return dp[ind] = min(left, right);
}

void solve()
{

    cin >> n;
    f0(i, n) cin >> a[i];
    ini(dp, -1);
    cout << frogA(0);








}//solve end




/////////////////////DRIVER FUNCTION/////////////////
signed main()
{

    input_File();

    lol


    //0 mane no test case......1 mane test case ache

    int isTestCasePresent = 0 ;
    if (isTestCasePresent == 0)
    {
        int t = 1;
        while (t--)
        {
            solve();
        }
    }
    else
    {
        tc(t)
        {
            solve();


        }
    }





    rr


}

Measured memory_bytes: 9872