stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long long int lli;

typedef long double ld;

const int oo = 1e9;

const int mod = 1e9+9;

/*ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }

*ll lcm(ll x, ll y){return x*(y/gcd(x,y));}

*void exEuclid(int a, int b){

	if(b==0){x = 1; y=0; d=a; return ;}

	exEuclid(b, a%b);

	int x1=y;

	int y1=x-(a/b)*y;

	x=x1;

	y=y1;

} 

* */

//===========================================================//

const int nax = 1e5+3;

int n;

int dp[nax];

int a[nax];

int f(int i){

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

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

	int ans = abs(a[i]-a[i+1])+f(i+1);

	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));

	return dp[i]=ans;

}

int main(){

	cin>>n;

	for(int i=0; i<n; i++) cin>>a[i];

	memset(dp, -1, sizeof dp);

	cout<<f(0)<<endl;

	return 0;

}

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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll dp[100009];

ll n,x;

vector<ll>v;

ll frog(ll pos)

{

    if(pos<=0)

        return 0;

    if(pos==1)

        return abs(v[0]-v[1]);

        if(dp[pos]==-1)

        {

            dp[pos]= min(abs(v[pos]-v[pos-1])+frog(pos-1),abs(v[pos]-v[pos-2])+frog(pos-2));

        }

    return dp[pos];

}



int main()

{

    cin>>n;

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

    for(ll i=0; i<n; i++)

    {

        cin>>x;

        v.push_back(x);

    }

    cout<<frog(n-1)<<endl;

}


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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

int v[1000010];

int memo[1000010];

int c;



int f(int i)

{



    if(memo[i]!=-1)

        return memo[i];



    if(i == 0)

        return memo[0] = 0;



    if(i == 1)

        return memo[1] = abs(v[0] - v[1]);



    return memo[i] = min(abs(v[i] - v[i-1]) + f(i-1), abs(v[i] - v[i-2]) + f(i-2));

}



int main()

{



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

    cin>>c;



    for(int i = 0; i<c; i++)

    {

        cin>>v[i];

    }



    cout<<f(c-1)<<endl;



    return 0;

}

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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int h[100001];

int dp[100001];

int n;

int solve(int stone)

{

    if(stone+1==n) return dp[stone]=abs(h[stone]-h[stone+1]);

    if(stone+2==n) return dp[stone+2]=abs(h[stone]-h[stone+2]);

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

    return dp[stone]=min(abs(h[stone]-h[stone+1])+solve(stone+1),abs(h[stone]-h[stone+2])+solve(stone+2));

}



int main()

{

    int i;

    scanf("%d",&n);



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

        scanf("%d",&h[i]);



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

    printf("%d\n",solve(1));





    return 0;

}


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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int n, h[100002], dp[100002];



int sol(int i){

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

    if(i>=n) return 1E9;



    int &ret = dp[i];

    if(~ret) return ret;



    return ret = min(abs(h[i+1]-h[i]) + sol(i+1),

                     abs(h[i+2]-h[i]) + sol(i+2));

}



int main()

{

    cin >> n;

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

        cin >> h[i];



    memset(dp, -1, sizeof dp);

    cout << sol(0);

}


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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// 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.382256814265018x):
#include <bits/stdc++.h>

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



#define F first

#define S second



int N;

int H[100005];

int dp[100005][5];



int solve(int cost, int ind, int j) {

	if (ind > N) return INT32_MAX;

	if (ind == N) return cost;



	if (~dp[ind][j]) return dp[ind][j];

	

	dp[ind][j] = cost;

	dp[ind][j] += min(solve(abs(H[ind] - H[ind + 1]), ind + 1, 0), 

					solve(abs(H[ind] - H[ind + 2]), ind + 2, 1));

	return dp[ind][j];

}



int main() {

	cin >> N; 

	H[0] = INT32_MAX; // to avoid RTE

	for (int i = 1; i <= N; i++) cin >> H[i];

	int ans = 0;

	

	memset(dp, -1, sizeof dp);

	cout << solve(0, 1, 0) << endl;



	return 0;

}

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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define ull unsigned long long

#define PII pair<int,int>

#define PSI pair<string,int>

#define PIII pair< int, pair<int,int> >

const int MXN = 1e5;

int a[MXN+5], dp[MXN+5];

int N,K;



int rec(int pos){



    if(pos==N) return 0;

    if(pos>=N) return 1<<30;

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

    return dp[pos] = min( rec(pos+1) + abs(a[pos+1]-a[pos]) , rec(pos+2) + abs(a[pos+2]-a[pos]) );

}



void solve(){



    cin>>N;

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

    for(int i=1; i<=N; i++) cin>>a[i];

    cout<< rec(1) << "\n";

}



int main(){



    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    solve();

}


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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int n;

int h[100005];

int dp[100005];



int solve(int x){

    if (x >= n-1) return 0;

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

    else if (x == n-2){

        return dp[x] = abs(h[x+1]-h[x]);

    }

    else {

        return dp[x] = min(abs(h[x+1]-h[x])+solve(x+1),abs(h[x+2]-h[x])+solve(x+2));

    }

}



int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cin >> n;

    memset(&dp,-1,sizeof(dp));

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

        cin >> h[i];

    }

    cout << solve(0) << endl;

    return 0;

}

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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// Slower C++ solution:
#include <bits/stdc++.h>

#define inf INFINITY

#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ;

#define Gamed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define _3102_ main()

#define endl '\n'

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

using namespace std;

const int N = 1e5 + 100;

const ll MX = 1e9;

const ll mod = 1e9 + 7;

const double eps = 1e-9 ;



ll n, h[N], dp[N] ;

ll solve( int i ){

	if ( i < 0 ) return 0 ;

	ll &ret = dp[i] ;

	if ( ~ret ) return ret ;

	if ( i == 0 ) return ret = 0 ;

	if ( i == 1 ) return ret = abs( h[1] - h[0]) ; 

	return ret = min ( solve(i - 1 ) + abs(h[i] - h[i-1]) , solve ( i - 2 ) + abs ( h[i] - h[i-2])) ;

}



int _3102_{

	Gamed

	cin >> n ;

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

		cin >> h[i] ;

	}

	memset ( dp , -1 , sizeof dp ) ;

	cout << solve ( n - 1 ) ;



	return 0;

}


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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// Slower C++ solution:
#include <bits/stdc++.h>



#define fst first

#define snd second

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

#define pb push_back

#define ALL(s) s.begin(),s.end()

#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define SZ(s) int(s.size())

#define DBG(x) cerr <<#x << " = " << (x) << "\n"



#define SQR(x) ((x) * (x))



#define PI 3.1415926535897932385

#define INF 1000111222

#define eps 1e-7

#define maxN 11



using namespace std;



typedef long long ll;

typedef vector<ll> vll;

typedef pair<ll,ll> pll;

typedef pair<int,int> pii;

typedef vector<string> vstr;

typedef vector<vll> vvll;

typedef vector<bool> vbool;

typedef vector<pll> vpll;

typedef vector<vpll> vvpll;

typedef vector<vbool> vvbool;



vll ns,dp;

ll n;



ll solve(ll pos){

	ll & d = dp[pos];

	if(d != -1) return d;

	ll v=INF;

	if((pos+1)<n)v = min(v,abs(ns[pos+1]-ns[pos])+solve(pos+1));

	if((pos+2)<n)v = min(v,abs(ns[pos+2]-ns[pos])+solve(pos+2));

	if(pos == (n-1)) v = 0;

	return d = v;

}



int main(){FIN

	

	cin >> n;

	ns.resize(n);

	dp.assign(100010,-1);

	fore(i,0,n)cin >> ns[i];

	

	solve(0);

	

	cout << dp[0] << "\n";



	return 0;

}


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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define fi first

#define se second

#define pb push_back

#define dbg(x) cout << #x << " = " << x << endl

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



typedef long long ll;

typedef long double ld;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;

typedef vector<vi> vvi;

typedef vector<pii> vii;



const int MAX = 1e5;

const int INF = 1e9;

vi stone(MAX + 5);

vi dp(MAX + 5, -1);

int n;



int sol(int i){

    if(i >= n) return INF;

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

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

    dp[i] = sol(i + 1) + abs(stone[i] - stone[i + 1]);

    if(i + 2 < n){

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

    }

    return dp[i];

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    #ifdef LOCAL

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

    #else

        #define endl '\n'

    #endif

    cin >> n;

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

        cin >> stone[i];

    cout << sol(0) << endl;

    return 0;

}

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

#define f first

#define s second

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

#define pb push_back

#define all(s) begin(s), end(s)

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sz(s) int(s.size())

#define ENDL '\n'

using namespace std;

typedef long double ld;

typedef long long lli;

typedef pair<lli,lli> ii;

#define deb(x) cout << #x": " << (x) << endl;



int main(){ _

  lli n;

  cin >> n;

  vector <lli> a(n);

  lli x;

  fore (i,0,n){

    cin >> x;

    a[i] = x;

  }

  vector <lli> b(n);

  b[0] = 0;

  b[1] = abs(a[0] - a[1]) + b[0];

  fore (i,2,n){

    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){

      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];

    }

    else{

      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];

    }

  }

  cout << b[n - 1] << ENDL;

  return 0;

}

// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.