stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <cstring>

using namespace std;



int n;

int ht[100010];

int eg[100010];//eg[i] 代表到达i点消耗的最少能量 

int main(){

	cin>>n;

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

		cin>>ht[i];

		

	}//读取完毕

	memset(eg, 0, sizeof(eg));

	eg[2] = abs(ht[2]- ht[1]);

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

		int t1 = abs(ht[i] - ht[i-1]);

		int t2 = abs(ht[i] - ht[i-2]);

		eg[i] = min(eg[i-1]+t1, eg[i-2]+t2); 

	}

	cout<<eg[n]<<endl;

		

}

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

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<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.7962627884530749x):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<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.7891018581578702x):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<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: 2.5805981163350817x):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<endl;



    return 0;

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

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

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

#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";

#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";

#define     watch(a)        cout<<fixed<<setprecision(a)

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

#define     Endl            "\n";

#define     tab             "\t"

#define     reset(a,b)      memset(a,b,sizeof(a));

#define     sf(a)           scanf(" %d", &a);

#define     srt(a)          sort(a.begin(),a.end());

#define     pi              2*acos(0.0)

#define     inf             INT_MAX

const int sz=1e5+9;

int n,x,arr[sz],dp[sz];



int clac(int i){

    if(i==n) return 0;

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

    int left=abs(arr[i]-arr[i+1])+clac(i+1);

    int right=inf;

    if(i+2<=n){

        right=abs(arr[i]-arr[i+2])+clac(i+2);

    }

    return dp[i]=min(left,right);

}









void solve(){



    cin>>n;





    reset(dp,-1);

    //bug(n,dp[n]);

    lp(i,1,n+1)cin>>arr[i];

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



}



int main(){

    //FasterIO;

   // #ifndef ONLINE_JUDGE

      //  freopen("1.txt","r",stdin);

   // #endif

    //int t;

    //cin>>t;

    //while(t--)

        solve();

}


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

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<endl;



    return 0;

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

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

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

#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";

#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";

#define     watch(a)        cout<<fixed<<setprecision(a)

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

#define     Endl            "\n";

#define     tab             "\t"

#define     reset(a,b)      memset(a,b,sizeof(a));

#define     sf(a)           scanf(" %d", &a);

#define     srt(a)          sort(a.begin(),a.end());

#define     pi              2*acos(0.0)

#define     inf             INT_MAX

const int sz=1e5+9;

int n,x,arr[sz],dp[sz];



int clac(int i){

    if(i==n) return 0;

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

    int left=abs(arr[i]-arr[i+1])+clac(i+1);

    int right=inf;

    if(i+2<=n){

        right=abs(arr[i]-arr[i+2])+clac(i+2);

    }

    return dp[i]=min(left,right);

}



void solve(){

    cin>>n;

    reset(dp,-1);

    lp(i,1,n+1)cin>>arr[i];

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

}



int main(){

    //FasterIO;

    #ifndef ONLINE_JUDGE

       // freopen("1.txt","r",stdin);

   #endif

   // int t;

    //cin>>t;

    //while(t--)

        solve();

}


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

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<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: 9.288482881558773x):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<endl;



    return 0;

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

#define f(i,s,v) for(int i=(int)s;i<(int)v;++i)

#define rf(i,s,v) for(int i=(int)s-1;i>(int)v;--i)

#define pb push_back

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

#define memset(c, value) memset(c, (int)value, sizeof(c))

using namespace std;

typedef long long ll;

const int oo = 1e9;

const ll MOD =1e9+7;

void fast(){

    ios_base :: sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

int n;

int h[100005];

bool valid (int r,int c){

    return (r < n && r >= 0 && c >= 0 && c < n);

}

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

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

int vis[100002];

int dp(int i){

    if(i == n-1)

        return 0;

    int &ret = vis[i];

    if(ret != -1)

        return ret;



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

    if(i+2 < n)

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

    return ret = path1;

}



int main()

{

    fast();

    memset(vis, -1);

    cin>>n;

    f(i,0,n)

        cin>>h[i];

    cout<<dp(0)<<'\n';

    return 0;

}


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

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<endl;



    return 0;

}
// Slower C++ solution:
#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;

}


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

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<endl;



    return 0;

}
// Slower C++ solution:
/*

** author:mahmoud magdy

*/

#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define endl "\n"



inline int D()

{

    int m ;

    cin>>m;

    return m ;

}

inline ll lD()

{

    ll m ;

    cin>>m;

    return m ;

}

inline double dD()

{

    double m;

    cin>>m;

    return m;

}

void fast()

{

    ios_base :: sync_with_stdio( 0 ) ;

    cin.tie( 0 ) ;

    cout.tie( 0 ) ;

}

int a[100005];

int dp[100005];

int n;

int solve(int i){

 if(i>=n)return 1e9;

 if(i==n-1)

    return 0;

 if(dp[i]!=-1)

      return dp[i];

 int ch1=abs(a[i]-a[i+1])+solve(i+1);

 int ch2=abs(a[i]-a[i+2])+solve(i+2);

 return dp[i]=min(ch1,ch2);

}

int main()

{

    fast();

    n=D();

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

        a[i]=D();

    }

    memset(dp,-1,sizeof dp);

    cout<<solve(0)<<endl;

}


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

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<endl;



    return 0;

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

using namespace std;

const int N = 1e5+1;



vector<int> v(N, 0);

vector<int> memo(N, -1);



int cost(int pos, int n){

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

    else if (pos == n) return 0;

    else if (pos == n-1) return (abs(v[n-1] - v[n]));

    else {

        memo[pos] = min(abs(v[pos] - v[pos + 1]) + cost(pos+1, n), abs(v[pos]-v[pos + 2]) + cost(pos+2, n));

        return memo[pos];

    }

}



int main(){

    int n; cin >> n;

    

    for (int i = 1; i!=n+1; i++) cin >> v[i];

    cout << cost(1, n) << endl;



    return 0;

}

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

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<endl;



    return 0;

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

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f

#define INF 0x3f3f3f3f

#define pb push_back

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

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

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

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

using namespace std;

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef pair<long long, int> pli;

typedef pair<long long, long long> pll;

const int mod = 1e9 + 7;

const int N = 1e5+10;

const int M = 1e6+10;

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

inline ll Pow(ll a, ll b) { ll ans = 1; for( ; b; b >>= 1) { if(b&1) ans = ans * a % mod; a = a * a % mod;} return ans;}

inline ll Mul ( ll a, ll b)  { ll lf = a * ( b >> 25ll ) % mod * ( 1LL << 25 ) % mod; ll rg = a * ( b & ( ( 1ll << 25 ) - 1 ) ) % mod; return ( lf + rg ) % mod;}

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



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



int main() {

   scanf("%d", &n);

   ms(dp, inf); dp[n] = 0;

   for1(i, n) scanf("%d", h+i);

   for(int i = n; i; --i) {

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

      else {

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

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

      }

   }

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

   return 0;

}

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

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<endl;



    return 0;

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

using namespace std;



#define clr(arr,val) memset(arr,val ,sizeof arr)

//#define first f

//#define second s



typedef  long long ull;

typedef long long ll;

int const oo=(int)1e9 ;



int const SZ= (int)1e5+1;

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

int arr[SZ];

int dp[SZ];

int n;

//int mn=oo;

int solve(int i){

    

    if(i==n-1)

        return 0;

    if(i>=n)

        return oo;

    

    int &ret=dp[i];

    

    if(ret!=-1)

        return ret;

        

    int ch1=abs(arr[i]-arr[i+1])+solve(i+1);

    int ch2=abs(arr[i]-arr[i+2])+solve(i+2);

    ret=min(ch1,ch2);

    return ret;

    

}

int main() {

//    int t ;

//    cin>>t;

//    while(t--){

        cin>>n;

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

            cin>>arr[i];

        clr(dp,-1);

        cout<<solve(0)<<endl;

//    }

    return 0;

}

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

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<endl;



    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.7666195750658176x):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef vector<int> vi;

#define PB push_back

#define MP make_pair

#define endl '\n'

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

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



int n;

int arr[100005];

int dp[100005];







int main()

{

    optimize();

    cin>>n;

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

        cin>>arr[i];

    dp[2]=abs(arr[1]-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]<<endl;



    return 0;

}