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

using namespace std;



const int N=1e5+30;

typedef long long ll;

int n,arr[N];

int dp[N];

ll solve(int i){

    if(i>=n)return 1e15;

    if(i==n-1){

        return 0;

    }



    if(dp[i]!=-1)return dp[i];



    ll path1=abs(arr[i]-arr[i+1])+solve(i+1);

    ll path2=abs(arr[i]-arr[i+2])+solve(i+2);

    return dp[i]= min(path1,path2);

}

int main()

{

    memset(dp,-1,sizeof dp);

    scanf("%d",&n);

    for(int i=0;i<n;i++)scanf("%d",arr+i);

    cout<<solve(0)<<endl;

}




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

}