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

#define endl '\n'

using namespace std;

typedef long long ll;

const int c=1e6;

const ll mod=1e9+7;

vector<pair<ll,ll> >v;

map<pair<ll,ll> ,bool>visited;

set<ll>s[10];

bool p[1000];

void sieve(){

p[0]=p[1]=1;

for(int i=2;i<=100;i++){

    for(int j=i*i;j<=100;j+=i){

        p[j]=1;

    }

}

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    ll n,x;

    cin>>n;

    ll arr[n+5];

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

        cin>>arr[i];

    }

    ll dp[n+5];

    ll ans=1e16,a,b;

    dp[1]=0;

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

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

            a=abs(arr[i-1]-arr[i]);

    b=abs(arr[i-2]-arr[i]);

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

    }

    cout<<dp[n];

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.310962646166586x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#define ll long long



using namespace std;



int main()

{

    ll n,arr[100005],dp[100005];

    cin>>n;

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

        cin>>arr[i];

    dp[0]=0;

    dp[1]=abs(arr[0]-arr[1]);

    if(n>2) dp[2]=abs(arr[0]-arr[2]);

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

    {

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

    }

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

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.439516358637754x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

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

using namespace std;



#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);

#define ll long long

#define pb push_back

#define endl '\n'

#define mod 1000000007

#define maxN 100005

const int inf=0x3f3f3f3f;



int arr[maxN], dp[maxN];



int main() {

	Omar45

    int n; cin >> n;

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

    for (int i=0; i<=n; i++) dp[i] = mod;

    //memset(dp, mod, sizeof(dp));

    dp[0] = 0;

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

        if (i+1<n) dp[i+1]= min(dp[i+1], dp[i]+abs(arr[i]-arr[i+1]));

        if (i+2<n) dp[i+2]= min(dp[i+2], dp[i]+abs(arr[i]-arr[i+2]));

    }

    cout << dp[n-1] << endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.313992039711126x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

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

using namespace std;

int n;

long long h[100005];

long long dp[100005];



long long solve(int i){

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

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



	dp[i] = 1e17;

	if(i+1 <= n-1)

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

	if(i+2 <= n-1)

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



	return dp[i];

}



int main(){

	scanf("%d", &n);

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

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

	memset(dp, -1, sizeof dp);

	cout<<solve(0)<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 9.455930458622328x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

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



#define ll long long

#define ld long double

#define ull unsigned long long

#define endl "\n"

#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);

#define f(a, b, c) for(int a = b; a < c; a++)

using namespace std;

const ll mod = 1e9 + 7;







//ll fact[1000001]; ll inv[1000001];

//ll primes[100007];

//ll arr[1000007];

//ll modPower(ll b, ll p) {

//	if (p == 0)

//		return 1;

//

//	ll halfpow = modPower(b, p / 2);

//	ll toReturn = (halfpow * halfpow) % mod;

//	if (p % 2)

//		toReturn = (toReturn * b) % mod;

//

//	return toReturn;

//}

//

//ll fastPower(ll b, ll p) {

//	if (p == 0)

//		return 1;

//	ll ans = fastPower(b, p / 2);

//	ans = (ans * ans);

//	if (p % 2 != 0)

//		ans = (ans * b);

//	return ans;

//}

//ll GcdRecursive(ll a, ll b) {

//	if (b == 0) return a;

//	return GcdRecursive(b, a % b);

//}

//ll modLCM(ll a, ll b) {

//	ll val = GcdRecursive(a, b);

//	ll tmp = ((a % mod) * (b % mod)) % mod;

//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;

//	return finalVal;

//

//}

//ll LCM(ll a, ll b) {

//	return (a * b) / GcdRecursive(a, b);

//}

//void move1step(ll& a, ll& b, ll q) { // a and b by reference

//	ll c = a - q * b;

//	a = b;

//	b = c;

//}

//ll GcdIterative(ll a, ll b) {

//	while (b) move1step(a, b, a / b);

//	return a;

//}

//

//void pre(ll n) {

//

//	fact[0] = 1;

//	inv[0] = 1;

//

//	for (ll i = 1; i <= n; i++) {

//		fact[i] = (i * fact[i - 1]) % mod;

//		inv[i] = modPower(fact[i], mod - 2);

//		arr[i] = modPower(i, mod - 2);

//	}

//}

//

//ll npr(ll n, ll r) {

//	return ((fact[n] * inv[n - r]) % mod);

//}

//

//ll ncr(ll n, ll r) {

//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);

//}

//

//void sieve(ll val) {

//	memset(primes, 1, sizeof primes);

//	primes[0] = primes[1] = false;

//	for (int i = 2; i <= val; i++) {

//		if (primes[i]) {

//			for (int j = i * i; j <= val; j += i) {

//				primes[j] = 0;

//			}

//		}

//	}

//

//}





const ll N = 1e5 + 7;



ll x;

ll a[N] = {};

ll dp[N] = {};



int main()

{

    MohamedMotaz;

    

    cin >> x;



    f(i, 0, x) cin >> a[i];

    dp[0] = 0;

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

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

    cout << dp[x - 1];



   



}














// Faster C++ solution for the same problem (measured speedup: 5.306760004456147x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

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

using namespace std;

int dp[200005];

int a[200005];

int main()

{

    int n;

    cin>>n;



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

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

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

    {

        int x=dp[i-1]+abs(a[i]-a[i-1]);

        int y=dp[i-2]+abs(a[i]-a[i-2]);

        //cout<<x<<" "<<y<<endl;

        dp[i]=min(x,y);

    }

    cout<<dp[n]<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.245885562263831x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

}
// Slower C++ solution:
#include <iostream>



using namespace std;



#define MAX_N 100000

int height[MAX_N];

int cost[MAX_N];

int n;



int main()

{

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    cin >> n;

    int i;

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

        cin >> height[i];

    }

    cost[1] = abs(height[1] - height[0]);

    for(i = 2; i < n; ++i){

        cost[i] = cost[i - 1] + abs(height[i] - height[i - 1]);

        cost[i] = min(cost[i], cost[i - 2] + abs(height[i] - height[i - 2]));

    }

    cout << cost[n - 1] << '\n';

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.3142033317818x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>



using namespace std;



int main()

{

    int N;

    scanf("%d",&N);

    int h[N+1];

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

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

    int f[N+1];

    f[1]=0;

    f[2]=abs(h[2]-h[1]);

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

        f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));

    printf("%d\n",f[N]);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.182631501441933x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

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

using namespace std;

int n;

long long h[100100], dp[100100];

int main(){

   ios::sync_with_stdio(0);

   cin >> n;

   for (int i=2; i<=n+1; i++) cin >> h[i];

   dp[2] = 0;

   dp[3] = abs(h[3] - h[2]);

   for (int i=4; i<=n+1; i++) dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));

//   for (int i=2; i<=n+1; i++) cout << dp[i] << ' ';

  // cout << endl;

   cout << dp[n+1] << endl;

   return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.319928866271386x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cmath>

#include<cstring>

#include<iostream>

#include<vector>

#include<stack>

#define maxn 100005

using namespace std;



int main(void)

{

    int n;

    cin >> n;

    int h[maxn];

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

        cin >> h[i];

    }

    int dp[maxn];

    dp[0]=0;

    dp[1]=0;



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

        int a,b;

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

        if(i-2 > 0)

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

        else b=0x7fffffff;

        dp[i] = min(a, b);

    }

    cout << dp[n];

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.317845064997506x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

}
// Slower C++ solution:
#include "bits/stdc++.h"



using namespace std;



typedef pair<int, int> pii;

typedef long long ll;



#define MAX_N 100000



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



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);



    cin >> N;



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

        cin >> h[i];



    dp[1] = abs(h[1] - h[0]), dp[0] = 0;



    for (int i = 2; i < N; i++) {

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

    }



    cout << dp[N - 1] << "\n";



    // --------------------

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.317582835061218x):
#include<cstdio>

#include<algorithm>

#include<cstdlib>

using namespace std;

const int maxn=100005;

int cost[maxn],dp[maxn];

int main(){

    int n;

    scanf("%d",&n);

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

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

    }

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

    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));

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

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

    }

    printf("%d",dp[n]);

    return 0;

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

using namespace std;

#define N (int)2e5

int n,memo[N],c[N];



int dp(int curr) {

    if (curr == n) return 0;

    if (curr > n) return 1e9;

    int &sol = memo[curr];

    if (sol != -1) return sol;

    sol = min(

        dp(curr + 1) + abs(c[curr] - c[curr + 1]) ,

        dp(curr + 2) + abs(c[curr] - c[curr + 2])

    );

    return sol;

}



int main() {

    scanf("%d" , &n);

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

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

    memset (memo , -1 , sizeof memo);

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

}


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

#include <vector>

using namespace std;

int main(){

	int n;

	cin>>n;

	vector <int> h(n),dp(n,INT_MAX);

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

	dp[0]=0;

	dp[1]=abs(h[1]-h[0]);

	dp[2]=min(abs(h[2]-h[0]),dp[1]+abs(h[2]-h[1]));

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

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

	}

	

	cout<<dp[n-1];

	return 0;

}
// Slower C++ solution:
#include<set>

#include<map>

#include<cmath>

#include<ctime>

#include<queue>

#include<stack>

#include<cstdio>

#include<string>

#include<vector>

#include<random>

#include<cstdlib>

#include<cstring>

#include<iomanip>

#include<iostream>

#include<algorithm>

#include<unordered_map>

#define endl "\n"

#define fi first

#define se second

#define db double

#define gcd __gcd

#define pb push_back

#define mp make_pair

#define lowbit(x) (x & (-x))

#define PII  pair<int, int> 

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

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

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

#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)

#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }

template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }

typedef long long ll;

typedef unsigned long long ull;

const db eps = 1e-9;

const db PI = acos(-1);

const int inf = 0x3f3f3f3f;

const int mod = (int)1e9 + 7;

const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE

const ll INF = 0x3f3f3f3f3f3f3f3f;

using namespace std;

ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }



inline int read(){

	char ch = getchar();

	int x = 0, f = 1;

	while(ch < '0' || ch > '9'){

		if(ch == '-') f = -1;

		ch = getchar();

	}

	while('0' <= ch && ch <= '9'){

		x = x * 10 + ch - '0';

		ch = getchar();

	}

	return x * f;

}



int n;

int h[maxn], dp[maxn];



int main()

{

	n = read();

	rep(i, 1, n) h[i] = read();

	memset(dp, 0x3f, sizeof dp);

	dp[1] = 0;

	rep(i, 1, n){

		dp[i+1] = qmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));

		dp[i+2] = qmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));

	}

	printf("%d\n", dp[n]);

	return 0;

}

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

#include <vector>

using namespace std;

int main(){

	int n;

	cin>>n;

	vector <int> h(n),dp(n,INT_MAX);

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

	dp[0]=0;

	dp[1]=abs(h[1]-h[0]);

	dp[2]=min(abs(h[2]-h[0]),dp[1]+abs(h[2]-h[1]));

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

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

	}

	

	cout<<dp[n-1];

	return 0;

}
// Slower C++ solution:


/**

    And in the end, the love you take is equal to the love you make.



        I LOVE YOU LAURA.

**/



#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#include <ext/rope>



#define _CRT_SECURE_NO_DEPRECATE

#define _CRT_DISABLE_PERFCRIT_LOCKS



#define findOrder find_by_order

#define orderKey order_of_key



#define isOn(mask, i) (mask & (1 << i))

#define turn(mask, i) (mask |= (1 << i))

#define switch(mask, i) (mask &= ~(1 << i))

#define change(mask, i) (mask ^= (1 << i))

#define lowbit(mask) (mask & (-mask))

#define turnAll(mask, n) (mask = (1 << n) - 1)

#define switchLastBit(mask) (mask & (mask - 1))

#define turnLastZero(mask) (mask | (mask + 1))

#define modulo(x, mod) ((x) & (mod - 1))

#define log2(x) (31 - __builtin_clz(x))



#define mkp make_pair

#define pb push_back

#define pf push_front

#define eb emplace_back

#define ef emplace_front

#define ins insert

#define rsz resize

#define f first

#define s second

#define lb lower_bound

#define ub upper_bound



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

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

#define rall(x) rbegin(x), rend(x)



#define debug(x) (cerr << x << " ")



using namespace std;

using namespace __gnu_pbds;

using namespace __gnu_cxx;



typedef double db;

typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;



typedef pair<int, int> ii;

typedef pair<ll,ll> pll;

typedef pair<ld,ld> pdb;

typedef pair<int, ii> tri;

typedef complex<ld> cd;



typedef vector<int> vi;

typedef vector<ii> vii;

typedef vector<ld> vdb;

typedef vector<cd> vcd;

typedef vector<ll> vll;

typedef vector<string> vs;

typedef vector<vll> matrix;



typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;



const ll mod = 1e9+7;

const int maxn = 2e5+2;

const int pi = 2 * acos(0.0);

const db eps = 1e-9;



ll arr[maxn], dp[maxn];



int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);



    int n; cin >> n;



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

        cin >> arr[i];

    }



    memset(dp, 63, sizeof dp);



    dp[1] = 0;

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

        if (i <= 2){

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

        }

        else{

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

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

        }

    }



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



    return 0;

}


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

#include <vector>

using namespace std;

int main(){

	int n;

	cin>>n;

	vector <int> h(n),dp(n,INT_MAX);

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

	dp[0]=0;

	dp[1]=abs(h[1]-h[0]);

	dp[2]=min(abs(h[2]-h[0]),dp[1]+abs(h[2]-h[1]));

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

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

	}

	

	cout<<dp[n-1];

	return 0;

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

using namespace std;

#define ll long long int

#define dbl double

#define pi acos(-1)

#define sc1(a) scanf("%lld",&a)

#define sc2(a,b) scanf("%lld%lld",&a,&b)

#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

#define pb push_back



ll ara[1000005];



map<ll,ll>vis;

map<ll,ll>vis1;

map<ll,ll>pos;

map<ll,ll>high;

map<ll,ll>low;

map<string,ll>mp;

vector<ll>vec;

vector<ll>v;

stack<ll>q;

string str1[100];

string str2[100];

priority_queue<ll>pq;

ll dp[1000005],t;

ll mn=1000000;

ll call(ll id)

{

    if(id==t )return 0;

    if(dp[id]!=-1)

        return dp[id];

    ll p=call(id+1)+abs(ara[id+1]-ara[id]);

    ll q=100000000;

    if(id+2!=t+1)

        q=call(id+2)+abs(ara[id+2]-ara[id]);

    dp[id]=min(p,q);

    return dp[id];



}

int main()

{



    // ll t;

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

    sc1(t);

    for(ll i=1; i<=t; i++)

    {

        sc1(ara[i]);

    }

    cout<<call(1)<<endl;

    return 0;

}


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

#include <vector>

using namespace std;

int main(){

	int n;

	cin>>n;

	vector <int> h(n),dp(n,INT_MAX);

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

	dp[0]=0;

	dp[1]=abs(h[1]-h[0]);

	dp[2]=min(abs(h[2]-h[0]),dp[1]+abs(h[2]-h[1]));

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

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

	}

	

	cout<<dp[n-1];

	return 0;

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



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

#define for1(i, n) for (int i = 1; i <= int(n); ++i)

#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)

#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)

#define pb push_back

#define eb emplace_back

#define ms(a, x) memset(a, x, sizeof(a))

#define F first

#define S second

#define endl '\n'

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

#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;



using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());



const int N=1e5+5;

int dp[N];

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

	int n;

	cin>>n;

	vector<int> a(n);

	for(auto& it:a) cin>>it;

	ms(dp,INF);

	dp[0]=0;

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

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

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

	}

	cout<<dp[n-1];

    return 0;

}




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

#include <vector>

using namespace std;

int main(){

	int n;

	cin>>n;

	vector <int> h(n),dp(n,INT_MAX);

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

	dp[0]=0;

	dp[1]=abs(h[1]-h[0]);

	dp[2]=min(abs(h[2]-h[0]),dp[1]+abs(h[2]-h[1]));

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

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

	}

	

	cout<<dp[n-1];

	return 0;

}