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

#include <queue>

typedef long long ll;



using namespace std;



const int N=1e5+5;





int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

   int n,k=2;

   cin>>n;

   int arr[N]={},dp[N]={};

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

    cin>>arr[i];

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

   dp[0]=0;

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

   {



     for(int j=1;j<=k;j++)

     {

         if(i-j>=0)

         {

             if(dp[i]==-1)

             {

                 dp[i]=dp[i-j]+abs(arr[i]-arr[i-j]);

             }

             else

             {

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





             }





         }



     }









   }

   cout<<dp[n-1];



   return 0;

}


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

#include<cstring>

#include<algorithm>





using namespace std;



const long long inf= 1e10+ 123;

const int mx=1e5+123;

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



int solve( int i)

{

    if(i==n)

        return 0;



    if(dp[i]!= -1)

        return dp[i];



    int ret1, ret2;

    ret1= abs(h[i]- h[i+1])+ solve(i+1);

    if(i+2<=n)

        ret2= abs(h[i]- h[i+2])+ solve(i+2);

    else

        ret2= inf;

    return dp[i]=min(ret1, ret2);

}



int main()

{

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



    cin>> n;

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

        cin>> h[i];



    cout<< solve(1)<< endl;



    return 0;

}
// Slower C++ solution:
/*

				" اللهم صلي و سلم علي سيدنا محمد و علي اله وصحبه اجمعين "

*/





#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#define f for

#define ll long long

#define ull unsigned long long

#define endl "\n"

using namespace std;

#define BI  acos(-1)

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

void Open()

{

#ifndef ONLINE_JUDGE

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

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

#endif

}

ll gcd(ll a, ll b)

{

	return b == 0 ? a : gcd(b, a % b);

}

void madesetprobblem()

{

	//$ $

	//less than or equal => $ 1 \leq 100 $

	//  $(1 \le A,B \le 10^5 )$

	// a[i] => $a_i$

	// a[i][j] => $a_{i,j}$

	// double qoutes ''yext''

	/*

		image

		\begine{center}

		\includegraphics{image.jpg}

		\end{center}

	*/

	/*

		list

		\begin{itemize}

			\item first one

			\item second one

		\end{itemize}

	*/

}

int n;

vector<int>a(1e5 + 2),dp(1e5+2,-1);

int ans(int c = 0)

{

	if (c == n-1)

		return 0;

	int ans1 = INT_MAX, ans2 = INT_MAX;

	if (dp[c] != -1)

		ans1 = dp[c];

	else

	{

		if (c + 1 < n)

			ans1 = (abs(a[c] - a[c + 1]) + ans(c + 1));

		if (c + 2 < n)

			ans2 = (abs(a[c] - a[c + 2]) + ans(c + 2));

		dp[c] = min(ans1, ans2);

	}

	//cout <<c<<" "<< ans1 << " " << ans2 << endl;

	return min(ans1,ans2);

}

int main()

{

	// توكلت علي الله 

//Open();

	ios::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

	cin >> n;

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

	{

		cin >> a[i];

	}

	cout << ans();

}

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

#include<cstring>

#include<algorithm>





using namespace std;



const long long inf= 1e10+ 123;

const int mx=1e5+123;

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



int solve( int i)

{

    if(i==n)

        return 0;



    if(dp[i]!= -1)

        return dp[i];



    int ret1, ret2;

    ret1= abs(h[i]- h[i+1])+ solve(i+1);

    if(i+2<=n)

        ret2= abs(h[i]- h[i+2])+ solve(i+2);

    else

        ret2= inf;

    return dp[i]=min(ret1, ret2);

}



int main()

{

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



    cin>> n;

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

        cin>> h[i];



    cout<< solve(1)<< endl;



    return 0;

}
// Slower C++ solution:
#define __USE_MINGW_ANSI_STDIO

#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#include <unordered_set>

#include <unordered_map>



using namespace std;



typedef long long ll;

typedef long long ull;

typedef pair<ll, ll> ii;



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

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

#define endl		"\n"

#define fx(n)		fixed<<setprecision(n)

#define mk			make_pair	



void File()

{

#ifndef ONLINE_JUDGE

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

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

#endif

#ifdef ONLINE_JUDGE

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

	freopen("pyramid.in", "r", stdin);*/

#endif

}

void fast()

{

	ios::sync_with_stdio(NULL);

	cout.tie(NULL);

	cin.tie(NULL);

	//File();

}

const double pi = 2 * acos(0.0);

const ll oo = 0x3f3f3f3f;

const int MOD = 1e9 + 7;

const int nn = 1e5 + 15;

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

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



int n;

ll arr[nn];

ll dp[nn];

int main()

{

	fast();

	cin >> n;

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

		cin >> arr[i];

	memset(dp, oo, sizeof dp);

	dp[0] = 0;

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

	{

		if (i == 1)

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

		else

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

	}

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

	return 0;

}

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

#include<cstring>

#include<algorithm>





using namespace std;



const long long inf= 1e10+ 123;

const int mx=1e5+123;

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



int solve( int i)

{

    if(i==n)

        return 0;



    if(dp[i]!= -1)

        return dp[i];



    int ret1, ret2;

    ret1= abs(h[i]- h[i+1])+ solve(i+1);

    if(i+2<=n)

        ret2= abs(h[i]- h[i+2])+ solve(i+2);

    else

        ret2= inf;

    return dp[i]=min(ret1, ret2);

}



int main()

{

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



    cin>> n;

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

        cin>> h[i];



    cout<< solve(1)<< endl;



    return 0;

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

    

using namespace std;

vector<long long >dp(100001,-1);

vector<long long>num;

long long  erg(int n){

	if(dp[n]!=-1){

		return dp[n];

	}

	if(n<0){

		return 2000000000000;

	}

	if(n==0){

		return 0;

	}

	long long cmp1=max(num[n],num[n-1])-min(num[n],num[n-1]),cmp2=max(num[n],num[n-2])-min(num[n],num[n-2]);

	dp[n]= min(erg(n-1)+cmp1,erg(n-2)+cmp2);

	return dp[n];

}

int main() {

	int menge,numm;

	cin>>menge;

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

		cin>>numm;

		num.push_back(numm);

	}

cout<<erg(menge-1);

    return 0;

}

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

#include<cstring>

#include<algorithm>





using namespace std;



const long long inf= 1e10+ 123;

const int mx=1e5+123;

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



int solve( int i)

{

    if(i==n)

        return 0;



    if(dp[i]!= -1)

        return dp[i];



    int ret1, ret2;

    ret1= abs(h[i]- h[i+1])+ solve(i+1);

    if(i+2<=n)

        ret2= abs(h[i]- h[i+2])+ solve(i+2);

    else

        ret2= inf;

    return dp[i]=min(ret1, ret2);

}



int main()

{

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



    cin>> n;

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

        cin>> h[i];



    cout<< solve(1)<< endl;



    return 0;

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

#define ll long long

using namespace std;



ll n;

std::vector<ll> ara(100010);

ll dp[100010];



ll fnc(ll i){

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

  if(i == n)return 1<<30;

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

  ll res1 = abs(ara[i]-ara[i+1]) + fnc(i+1);

  ll res2 = abs(ara[i]-ara[i+2]) + fnc(i+2);

  dp[i] = min(res1,res2);

  return min(res1,res2);

}



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

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

  cin >> n;

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

    cin >> ara[i];

  }

  cout << fnc(0) << endl;



  return 0;

}


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

#include<cstring>

#include<algorithm>





using namespace std;



const long long inf= 1e10+ 123;

const int mx=1e5+123;

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



int solve( int i)

{

    if(i==n)

        return 0;



    if(dp[i]!= -1)

        return dp[i];



    int ret1, ret2;

    ret1= abs(h[i]- h[i+1])+ solve(i+1);

    if(i+2<=n)

        ret2= abs(h[i]- h[i+2])+ solve(i+2);

    else

        ret2= inf;

    return dp[i]=min(ret1, ret2);

}



int main()

{

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



    cin>> n;

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

        cin>> h[i];



    cout<< solve(1)<< endl;



    return 0;

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

using namespace std;

#define DEBUG

#ifdef DEBUG

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)

	template <typename Arg1>

	void __f(const char* name, Arg1&& arg1){

		cerr << name << " : " << arg1 << std::endl;

	}

	template <typename Arg1, typename... Args>

	void __f(const char* names, Arg1&& arg1, Args&&... args){

		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);

	}

#else

#define debug(...)

#endif

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

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

#define ln 		"\n"

#define mp make_pair

#define pb push_back

#define sz(a)	ll(a.size())

#define F first

#define S second

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

#define rall(c) c.rbegin(), c.rend()

#define trace(c,x) for(auto &x:c)

#define pii pair<ll,ll>

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

typedef long long ll;

typedef long double ld;

typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;



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

// ordered_set X

//K-th smallest

//*X.find_by_order(k-1)

//NO OF ELEMENTS < A

//X.order_of_key(A)

const int L=1e6+7;

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

ll solve(int i)

{

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

	if(i>=n)return INT_MAX;

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

	ll &ret = dp[i];

	ret = INT_MAX;

	ret = solve(i+1) + abs(h[i]-h[i+1]);

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

	return ret;

}

void fff()

{

	cin >> n;

	init(dp, -1);

	FOR(i,0,n)cin >> h[i];

	cout<<solve(0)<<ln;

}

int main()

{

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

	//int t;cin >> t;while(t--)

	fff();

	return 0;

}

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

#include<cstring>

#include<algorithm>





using namespace std;



const long long inf= 1e10+ 123;

const int mx=1e5+123;

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



int solve( int i)

{

    if(i==n)

        return 0;



    if(dp[i]!= -1)

        return dp[i];



    int ret1, ret2;

    ret1= abs(h[i]- h[i+1])+ solve(i+1);

    if(i+2<=n)

        ret2= abs(h[i]- h[i+2])+ solve(i+2);

    else

        ret2= inf;

    return dp[i]=min(ret1, ret2);

}



int main()

{

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



    cin>> n;

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

        cin>> h[i];



    cout<< solve(1)<< endl;



    return 0;

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

using namespace std;

#define    sz    100110

#define    ll    long long int

ll n,c=0,p,q;

ll num[sz];

ll vis[sz];

ll dp[sz];



ll tani(int pos)

{



  if(pos>=n)return 0;

  if(vis[pos]==1)return dp[pos];

  vis[pos]=1;



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



}



int main()

{

    ll t,i;



    for(i=1;i<sz;i++)num[i]=1000000;



    cin>>n;

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

    {

        cin>>num[i];

    }

    t=tani(1);

    cout<<t<<endl;

    return 0;

}


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

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

using namespace std;

//int vv[100003];

int main()

{

    sunil;

    int n,p,l,j=2;

    cin>>n;

    vector<int>v(n);

    for(auto &u :v) cin>>u;

    vector<int>vv(n);

   // if(v[i]>v[0])

   // vv.push_back=(v[1]-v[0]);

   // else vv.push_back(v[0]-v[1]);

   vv[1]=abs(v[1]-v[0]);



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

            p=abs(v[i]-v[i-1]);

            l=abs(v[i]-v[i-2]);

        vv[j]=min(p+vv[i-1],l+vv[i-2]);

        j++;

    }

   int  m=vv.size()-1;

    cout<<vv[m]<<endl;

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

using namespace std;



#define fr(i,n) _back

#define pb	push_back

#define eb	emplace_back

#define mk	make_pair

#define fi	first

#define se	second

#define endl	'\n'



typedef long long ll;

typedef pair<int,int> ii;

typedef vector<ii> vii;

const int INF = 0x3f3f3f3f;

const double PI = acos(-1.0);

const int N = 1e5 + 3;

int h[N];

int dp[N];



int main() {

    ios_base::sync_with_stdio(false);

    memset(dp, INF, sizeof dp);

    int n; cin >> n;

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



    dp[0] = 0;

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

        for(int j = max(0,i-2); j < i; j++)

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



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

    return 0;

}


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

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

using namespace std;

//int vv[100003];

int main()

{

    sunil;

    int n,p,l,j=2;

    cin>>n;

    vector<int>v(n);

    for(auto &u :v) cin>>u;

    vector<int>vv(n);

   // if(v[i]>v[0])

   // vv.push_back=(v[1]-v[0]);

   // else vv.push_back(v[0]-v[1]);

   vv[1]=abs(v[1]-v[0]);



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

            p=abs(v[i]-v[i-1]);

            l=abs(v[i]-v[i-2]);

        vv[j]=min(p+vv[i-1],l+vv[i-2]);

        j++;

    }

   int  m=vv.size()-1;

    cout<<vv[m]<<endl;

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

using namespace std;



int N, a[100100], dp[100100];



int f(int n) {

	if (n==1) return 0;

	if (n==2) return abs(a[2] - a[1]);

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

	dp[n] = min(

				f(n-1) + abs(a[n] - a[n-1]),

				f(n-2) + abs(a[n] - a[n-2])

				);

	return dp[n];

}



int main() {

	cin >> N;

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

		cin >> a[i];

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

	cout << f(N) << endl;

	return 0;

}

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

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

using namespace std;

//int vv[100003];

int main()

{

    sunil;

    int n,p,l,j=2;

    cin>>n;

    vector<int>v(n);

    for(auto &u :v) cin>>u;

    vector<int>vv(n);

   // if(v[i]>v[0])

   // vv.push_back=(v[1]-v[0]);

   // else vv.push_back(v[0]-v[1]);

   vv[1]=abs(v[1]-v[0]);



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

            p=abs(v[i]-v[i-1]);

            l=abs(v[i]-v[i-2]);

        vv[j]=min(p+vv[i-1],l+vv[i-2]);

        j++;

    }

   int  m=vv.size()-1;

    cout<<vv[m]<<endl;

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

using namespace std;

typedef long long LL;



int arr[100007];

int dp[100007];



int Solve(int idx, int n){

//	cout<<cost<<" "<<idx<<endl;

	if(idx >= n)return 1e9;

	if(idx == n - 1){

		return 0;	

	}

	

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

	

	

	return dp[idx] = min(abs(arr[idx] - arr[idx+1]) + Solve(idx+1, n), abs(arr[idx] - arr[idx+2]) + Solve(idx+2,n));

}



int main(){

	int n; cin>>n;

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

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

		

	cout<<Solve(0,n)<<endl;

	return 0;

}

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

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

using namespace std;

//int vv[100003];

int main()

{

    sunil;

    int n,p,l,j=2;

    cin>>n;

    vector<int>v(n);

    for(auto &u :v) cin>>u;

    vector<int>vv(n);

   // if(v[i]>v[0])

   // vv.push_back=(v[1]-v[0]);

   // else vv.push_back(v[0]-v[1]);

   vv[1]=abs(v[1]-v[0]);



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

            p=abs(v[i]-v[i-1]);

            l=abs(v[i]-v[i-2]);

        vv[j]=min(p+vv[i-1],l+vv[i-2]);

        j++;

    }

   int  m=vv.size()-1;

    cout<<vv[m]<<endl;

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

using namespace std;

int dp[100005];

int H[100005];

void memo(int i,int n)

{

	if(i==n) return;

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

	memo(i+1,n);

}

int main()

{

	int N;cin>>N;

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

	{

        cin>>H[i];

	}

	memset(dp,0,sizeof(dp));

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

	memo(2,N);

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

	return 0;

}

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

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

using namespace std;

//int vv[100003];

int main()

{

    sunil;

    int n,p,l,j=2;

    cin>>n;

    vector<int>v(n);

    for(auto &u :v) cin>>u;

    vector<int>vv(n);

   // if(v[i]>v[0])

   // vv.push_back=(v[1]-v[0]);

   // else vv.push_back(v[0]-v[1]);

   vv[1]=abs(v[1]-v[0]);



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

            p=abs(v[i]-v[i-1]);

            l=abs(v[i]-v[i-2]);

        vv[j]=min(p+vv[i-1],l+vv[i-2]);

        j++;

    }

   int  m=vv.size()-1;

    cout<<vv[m]<<endl;

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



using namespace std;



int dp[(int)1e5+5];

int main()

{



    ios_base::sync_with_stdio(0);cin.tie(0);







    fill(dp, dp+(int)1e5+5 , INT_MAX );



    dp[1] = 0;

    int n;

    cin>>n;

    vector <int> v(n+3,0);

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



        cin>>v[i];



    }

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



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

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



    }

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

}


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

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

using namespace std;

//int vv[100003];

int main()

{

    sunil;

    int n,p,l,j=2;

    cin>>n;

    vector<int>v(n);

    for(auto &u :v) cin>>u;

    vector<int>vv(n);

   // if(v[i]>v[0])

   // vv.push_back=(v[1]-v[0]);

   // else vv.push_back(v[0]-v[1]);

   vv[1]=abs(v[1]-v[0]);



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

            p=abs(v[i]-v[i-1]);

            l=abs(v[i]-v[i-2]);

        vv[j]=min(p+vv[i-1],l+vv[i-2]);

        j++;

    }

   int  m=vv.size()-1;

    cout<<vv[m]<<endl;

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



using namespace std;



#define REP(i,a,b) for(ll i = a; i < b; i++)

#define DB( x ) cout << #x << " = " << x << endl;

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

#define endl '\n'



typedef long long ll;

typedef unsigned long long ull;

typedef pair<ll, ll> pii;

typedef pair<int, pii> tri;

typedef vector <vector <ll>> matrix;

typedef pair<string, string> pss;



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

const int MAX = (int)1e6 + 100;



const ll oo = 0x3f3f3f3f3f3f3f3f;



ll dp[MAX], a[MAX];



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    memset(dp, oo, sizeof(dp));



    int n; cin >> n;



    dp[1] = 0;



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

        cin >> a[i];

    }



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

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

        if(i - 2 >= 1){

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

        }

    }



    cout << dp[n] << endl;

}


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

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

using namespace std;

//int vv[100003];

int main()

{

    sunil;

    int n,p,l,j=2;

    cin>>n;

    vector<int>v(n);

    for(auto &u :v) cin>>u;

    vector<int>vv(n);

   // if(v[i]>v[0])

   // vv.push_back=(v[1]-v[0]);

   // else vv.push_back(v[0]-v[1]);

   vv[1]=abs(v[1]-v[0]);



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

            p=abs(v[i]-v[i-1]);

            l=abs(v[i]-v[i-2]);

        vv[j]=min(p+vv[i-1],l+vv[i-2]);

        j++;

    }

   int  m=vv.size()-1;

    cout<<vv[m]<<endl;

}
// Slower C++ solution:
/*|In The Name Of Allah|*/



#include <bits/stdc++.h>



using namespace std;



const int N = 1e5+5;



int n;

int h[N];

int mem[N];



int go(int idx){

    if(idx >= n)

        return 0;

    if(mem[idx] != -1)

        return mem[idx];

    int best = 1e9;

    if(idx + 1 <= n)

        best = go(idx + 1) + abs(h[idx] - h[idx + 1]);

    if(idx + 2 <= n)

        best = min(best , go(idx + 2)  + abs(h[idx] - h[idx + 2]));

    return mem[idx] = best;

}



int main(){

    scanf("%d" , &n);

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

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

    }

    memset(mem , -1 , sizeof mem);

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

}

//1 2 3


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

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

using namespace std;

//int vv[100003];

int main()

{

    sunil;

    int n,p,l,j=2;

    cin>>n;

    vector<int>v(n);

    for(auto &u :v) cin>>u;

    vector<int>vv(n);

   // if(v[i]>v[0])

   // vv.push_back=(v[1]-v[0]);

   // else vv.push_back(v[0]-v[1]);

   vv[1]=abs(v[1]-v[0]);



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

            p=abs(v[i]-v[i-1]);

            l=abs(v[i]-v[i-2]);

        vv[j]=min(p+vv[i-1],l+vv[i-2]);

        j++;

    }

   int  m=vv.size()-1;

    cout<<vv[m]<<endl;

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

#define pii pair<int,int>

#define vi vector<int>

#define ppii pair<pii>



using namespace std;

const int maxn=1e5+5;



int n;

vi arr;

int dp[maxn];



int dfs(int pos)

{

    if(pos==n){return 0;}



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



    int ans=(1<<29);



    if(pos<n)

        ans=min(ans,dfs(pos+1) + abs(arr[pos]-arr[pos+1]));

    if(pos<n-1)

        ans=min(ans,dfs(pos+2) + abs(arr[pos]-arr[pos+2]));

    dp[pos]=ans;



    return ans;

}



int main()

{

    ios_base::sync_with_stdio(0);

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



    cin>>n;



    arr=vi(n+1);



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

        cin>>arr[i];



    memset(dp,-1,sizeof dp);



    cout<<dfs(1);



    return 0;

}


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

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

using namespace std;

//int vv[100003];

int main()

{

    sunil;

    int n,p,l,j=2;

    cin>>n;

    vector<int>v(n);

    for(auto &u :v) cin>>u;

    vector<int>vv(n);

   // if(v[i]>v[0])

   // vv.push_back=(v[1]-v[0]);

   // else vv.push_back(v[0]-v[1]);

   vv[1]=abs(v[1]-v[0]);



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

            p=abs(v[i]-v[i-1]);

            l=abs(v[i]-v[i-2]);

        vv[j]=min(p+vv[i-1],l+vv[i-2]);

        j++;

    }

   int  m=vv.size()-1;

    cout<<vv[m]<<endl;

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

#include <queue>

typedef long long ll;



using namespace std;



const int N=1e5+5;





int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

   int n,k=2;

   cin>>n;

   int arr[N]={},dp[N]={};

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

    cin>>arr[i];

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

   dp[0]=0;

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

   {



     for(int j=1;j<=k;j++)

     {

         if(i-j>=0)

         {

             if(dp[i]==-1)

             {

                 dp[i]=dp[i-j]+abs(arr[i]-arr[i-j]);

             }

             else

             {

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





             }





         }



     }









   }

   cout<<dp[n-1];



   return 0;

}


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

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

using namespace std;

//int vv[100003];

int main()

{

    sunil;

    int n,p,l,j=2;

    cin>>n;

    vector<int>v(n);

    for(auto &u :v) cin>>u;

    vector<int>vv(n);

   // if(v[i]>v[0])

   // vv.push_back=(v[1]-v[0]);

   // else vv.push_back(v[0]-v[1]);

   vv[1]=abs(v[1]-v[0]);



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

            p=abs(v[i]-v[i-1]);

            l=abs(v[i]-v[i-2]);

        vv[j]=min(p+vv[i-1],l+vv[i-2]);

        j++;

    }

   int  m=vv.size()-1;

    cout<<vv[m]<<endl;

}