// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;



#define pb                push_back

#define ppb               pop_back

#define pf                push_front

#define ppf               pop_front

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

#define int               long long

#define fr                first

#define sc                second

#define vc                vector

#define endl              '\n'

#define pii               pair<int,int>

#define msi               map<string,int>

#define mii               map<int,int>

#define psi               pair<string,int>

#define pis               pair<int,string>

#define mem1(a)           memset(a,-1,sizeof(a))

#define mem0(a)           memset(a,0,sizeof(a))

#define rep(i,a,b)        for(int i=a;i<b;i++)

#define LSB(i)            ((i)&-(i))



template<typename T>

using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



const int N = 1e5 + 5;

int dp[N];

int a[N];

int n;



int dynamic(int pos)

{

    if (pos > n)

        return INT_MAX;

    if (pos == n)

        return 0;

    if (dp[pos] != -1)

        return dp[pos];

    int ans;

    ans = min(dynamic(pos + 1) + abs(a[pos + 1] - a[pos]), dynamic(pos + 2) + abs(a[pos + 2] - a[pos]));

    dp[pos] = ans;

    return ans;

}



void solve()

{

    cin >> n;

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

        cin >> a[i];

    mem1(dp);

    cout << dynamic(1);

}

signed main() {

    ios_base::sync_with_stdio(false);

    //freopen("input.txt", "r", stdin);

    //freopen("output.txt", "w", stdout);

    int t = 1;

    //cin>>t;

    while (t--) solve();

    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;



#define pb                push_back

#define ppb               pop_back

#define pf                push_front

#define ppf               pop_front

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

#define int               long long

#define fr                first

#define sc                second

#define vc                vector

#define endl              '\n'

#define pii               pair<int,int>

#define msi               map<string,int>

#define mii               map<int,int>

#define psi               pair<string,int>

#define pis               pair<int,string>

#define mem1(a)           memset(a,-1,sizeof(a))

#define mem0(a)           memset(a,0,sizeof(a))

#define rep(i,a,b)        for(int i=a;i<b;i++)

#define LSB(i)            ((i)&-(i))



template<typename T>

using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



const int N = 1e5 + 5;

int dp[N];

int a[N];

int n;



int dynamic(int pos)

{

    if (pos > n)

        return INT_MAX;

    if (pos == n)

        return 0;

    if (dp[pos] != -1)

        return dp[pos];

    int ans;

    ans = min(dynamic(pos + 1) + abs(a[pos + 1] - a[pos]), dynamic(pos + 2) + abs(a[pos + 2] - a[pos]));

    dp[pos] = ans;

    return ans;

}



void solve()

{

    cin >> n;

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

        cin >> a[i];

    // mem1(dp);

    dp[1] = 0;

    dp[2] = abs(a[2] - a[1]);

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

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

    cout << dp[n];

}

signed main() {

    ios_base::sync_with_stdio(false);

    //freopen("input.txt", "r", stdin);

    //freopen("output.txt", "w", stdout);

    int t = 1;

    //cin>>t;

    while (t--) solve();

    return 0;

}

// Fastest known solution for this problem: