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

#include <algorithm>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cstring>

#include <vector>

#include <string>

#include <climits>

#include <map>

#include <set>

#include <stack>

#include <queue>

#include <deque>

#include <stdio.h>

//#define int long long

using namespace std;

#define loop(n) for(int i=0;i<n;i++)

#define endl '\n'

#define OnlineJudgec

#define F first

#define S second

#define  precision(n)  cout << fixed << setprecision(n)

#define clr(v,d ) memset(v, d, sizeof(v))

typedef long long ll;

typedef vector<int> vi;

void init()

{

    cin.tie(0);

    cin.sync_with_stdio(0);

    cout.tie(0);

    #ifdef OnlineJudge

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

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

    #endif

}

ll S(ll x){ll s = 0;while(x){s += x % 10;x /= 10;}return s;} /// sum of digits.

ll powe(ll a , ll n){if(n == 1)return a;return a * powe(a ,n-1);}

ll com(int n,int m){ll z = 1;for(int i = 0; i < m;i++){z = z * ( n - i) / (i + 1) ;}return z;}

int dx[] = {1,-1,0,0};

int dy[] = {0,0,1,-1};

int dr[] = {0,0,0,1,1,1,-1,-1,-1};

int dc[] ={-1,0,1,-1,0,1,-1,0,1};

/// <<------------------------------------------------------------------------------>>

const int mx = 100009;

int n;

int arr[mx];

int dp[mx];

int solve(int idx)

{

    if(idx == n-1)return 0;

    int &rst = dp[idx];

    if(~rst) return rst;

    int choice = 1e9 , choice2 = 1e9;

    if(idx + 1 < n)

        choice = solve(idx+1) + abs(arr[idx] - arr[idx + 1]);

    if(idx + 2 < n)

       choice2 = solve(idx+2) + abs(arr[idx] - arr[idx + 2]);

    return rst = min(choice , choice2);

}

/// <<------------------------------------------------------------------------------>>

int main()

{

    init();

    cin >> n;

    loop(n) cin >> arr[i];

    clr(dp,-1);

    cout<<solve(0);

}


// Faster C++ solution for the same problem (measured speedup: 1.39488803805749x):
#include <bits/stdc++.h>

using namespace std;

 

#define MOD (1000000007)

#define f first

#define s second

#define pb(x) push_back(x)

#define mp(x,y) make_pair(x,y)

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

#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

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

#define forr(i,a,b) for(int i = (a); i > (b); i--)

#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

typedef long long int ll;

#define ld long double

const int N = 2e5+30;

//https://codeforces.com/problemset/page/2?tags=1700-1700

 

 

void solve(){

   int n;

   cin>>n;

   int a[n+3];

   int dp[n+3];

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

     dp[i] = 1e9;

   }

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

     cin>>a[i];

   }

   dp[1]  = 0;

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

     if(i-1>=1){

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

     }

     if(i-2>=1){

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

     }

   }

   cout<<dp[n]<<'\n';

}

 

 

int main(){

 	ios_base::sync_with_stdio(false);

  cin.tie(NULL);

	int T;

  //cin >> T;

  //cout<<prs.size()<<'\n';

	 T = 1;

  //visited[1]=1;

	while(T--){

		solve();

	}

}