stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

ll mod = 998244353;

#define EPS 1e-1

#define PI 3.14159265



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

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

using namespace std;



ll fastpow(ll base, ll pow)

{

    if (!base)

        return 0;

    if (!pow)

        return 1;

    if (pow == 1)

        return base;

    ll x = fastpow(base, pow / 2) % mod;

    x *= x;

    x %= mod;

    if (pow % 2)

        x *= base;

    return x % mod;

}



ll inverse(ll x)

{

    return fastpow(x, mod - 2) % mod;

}



ll fact[(int)1e6 + 5], inv[(int)1e6 + 5];

void init()

{

    fact[0] = inv[0] = 1;

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

    {

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

        inv[i] = inverse(fact[i]);

    }

}



void factorize(ll x, map<int, int> &ss)

{

    while (x % 2 == 0)

        ss[2]++, x /= 2;

    for (int i = 3; i <= sqrt(x); i += 2)

        while (x % i == 0)

            ss[i]++, x/= i;

    if (x > 2)

        ss[x]++;

}



ll ncr(ll n, ll r)

{

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

}



ll npr(ll n, ll r)

{

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

}



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

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



int n;

ll arr[(int)1e5 + 5];

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



ll solve(int idx)

{

    if (idx == n)

        return 0;

    if (dp[idx] != -1)

        return dp[idx];

    ll res = 1e9;

    if (idx + 1 < n)

        res = min(res, abs(arr[idx] - arr[idx + 1]) + solve(idx + 1));

    else if (idx + 1 == n)

        res = min(res, solve(idx + 1));

    if (idx + 2 < n)

        res = min(res, abs(arr[idx] - arr[idx + 2]) + solve(idx + 2));

    else if (idx == n)

        res = min(res, solve(idx + 2));

    return dp[idx] = res;

}



int main()

{

    fastio

    cin >> n;

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

        cin >> arr[i];

    memset(dp, -1, sizeof dp);

    cout << solve(0);

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



const int N = 1e5 + 5;

const int steps = 2;

ll dp[N];

ll h[N];

int n;



int main() {

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

    cin >> n;

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

        cin >> h[i];

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

        ll start = max(0, i - steps), mn = 1e9;

        for (int j = start; j < i; j++)

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

        dp[i] = mn;

    }

    cout << dp[n - 1];

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

ll mod = 1e9 + 7;

#define EPS 1e-1

#define PI 3.14159265



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

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

using namespace std;



ll fastpow(ll base, ll pow)

{

    if (!base)

        return 0;

    if (!pow)

        return 1;

    if (pow == 1)

        return base;

    ll x = fastpow(base, pow / 2) % mod;

    x *= x;

    x %= mod;

    if (pow % 2)

        x *= base;

    return x % mod;

}



ll inverse(ll x)

{

    return fastpow(x, mod - 2) % mod;

}



ll fact[(int)1e6 + 5], inv[(int)1e6 + 5];

void init()

{

    fact[0] = inv[0] = 1;

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

    {

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

        inv[i] = inverse(fact[i]);

    }

}



void factorize(ll x, map<int, int> &ss)

{

    while (x % 2 == 0)

        ss[2]++, x /= 2;

    for (int i = 3; i <= sqrt(x); i += 2)

        while (x % i == 0)

            ss[i]++, x/= i;

    if (x > 2)

        ss[x]++;

}



ll ncr(ll n, ll r)

{

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

}



ll npr(ll n, ll r)

{

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

}



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

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



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

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

    int n;



ll solve(int idx)

{

    if (idx >= n - 1)

        return 0;

    if (dp[idx] != -1)

        return dp[idx];

    int c1 = 1e9;

    if (idx + 1 < n)

    {

        c1 = 0;

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

    }

    int c2 = 1e9;

    if (idx + 2 < n)

    {

        c2 = 0;

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

    }

    return dp[idx] = min(c1, c2);

}



int main()

{

    fastio

    memset(dp, -1, sizeof dp);

    cin >> n;

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

        cin >> arr[i];

    cout << solve(0);

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



const int N = 1e5 + 5;

const int steps = 2;

ll dp[N];

ll h[N];

int n;



int main() {

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

    cin >> n;

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

        cin >> h[i];

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

        ll start = max(0, i - steps), mn = 1e9;

        for (int j = start; j < i; j++)

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

        dp[i] = mn;

    }

    cout << dp[n - 1];

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define debug(x) cout << #x << " = " << x << '\n'



using ll = long long;

using namespace std;



const int N = 1e5 + 1;

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



int solve(int index)

{

	if (dp[index] != -1)

		return dp[index];

	

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

}



int main()

{

	ios_base::sync_with_stdio(false);

	cin.tie(nullptr);

	cout << setprecision(10) << fixed;



#ifdef LOCAL_DEFINE

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

#endif



	int n;

	cin >> n;

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

		cin >> h[i];



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

	dp[0] = 0;

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



	cout << solve(n - 1);



	

	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;



const int INF = 1e9;



int main() {

  ios_base::sync_with_stdio(0);

  cin.tie(0);

  int n;

  cin >> n;

  vector<int> a(n);

  for (auto &x : a)

    cin >> x;

  vector<int> dp(n, INF);

  dp[0] = 0;

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

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

    for (auto j : {i - 1, i - 2})

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

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

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ll long long int

#define INF INT_MAX

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

using namespace std;

ll dp[100006];

ll a[100006];

ll n;

ll rec(ll idx)

{

	

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

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

	ll ans=0;

	if(idx<n-2)

	{

		ans=min(abs(a[idx]-a[idx+1])+rec(idx+1),abs(a[idx]-a[idx+2])+rec(idx+2));

	}

	else ans=abs(a[idx]-a[idx+1])+rec(idx+1);

	return dp[idx]=ans;

}

int main()

{

	chutiyaap;

	cin>>n;

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

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

	cout<<rec(0);

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#define pb push_back

#define mp make_pair

#define ll long long int

#define INF INT_MAX

#define mod

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

using namespace std;



int main()

{

	chutiyaap;

	ll n;cin>>n;

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

	ll dp[n+1];

	dp[0]=0;

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

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

	{

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

	}

	cout<<dp[n-1];

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	long long int i,j,k,n,m,x,y,z,a[100000],b[100000]={0};

	cin>>n;

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

	cin>>a[i];

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

	{

		if(i==1)

		{

			x=a[i]-a[i-1];

			if(x<0)

			x=x*(-1);

			b[i]=x;

		}

		else

		{

			x=a[i]-a[i-1];

			y=a[i]-a[i-2];

			if(x<0)

			x=x*(-1);

			if(y<0)

			y=y*(-1);

			x=x+b[i-1];

			y=y+b[i-2];

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

		}

	}

	cout<<b[n-1];

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define max1 1000005

#define siz 100000

#define mod 998244353

#define inf 1e18+5

#define ll long long int

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

#define jam(x) cout<<"Case #"<<x<<": "

typedef pair<ll,ll> pr;

int main()

{

  ios_base::sync_with_stdio(false);

  cin.tie(NULL);

  cout.tie(NULL);

  /*#ifndef ONLINE_JUDGE

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

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

  #endif*/

  ll n;

  cin>>n;

  vector<ll> a(n);

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

  {

    cin>>a[i];

  }

  vector<ll> dp(n,0);

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

  {

    if(i==1)

    {

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

    }

    else

    {

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

    }

  }

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace         std;

#define                 int long long

#define                 pb push_back

#define                 mp make_pair

#define st(arr,a)       memset(arr,a,sizeof arr)

#define                 nl cout<<endl

#define                 real signed

#define                 endl '\n'              

#define bitcount(x)     __builtin_popcountll(x)

const int MOD = 1000000007ll;

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

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



int arr[100000+50000],n;



int dp[150000];



int ans(int ind)

{

    if(ind==n)return 0;

    if(ind>n)return MOD*MOD;



    if(dp[ind]>-1)return dp[ind];



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

    return dp[ind];

}



signed main() 

{

	ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cin>>n;

    st(dp,-1);

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



    cout<<ans(1);



    



     

     









     return 0;



}



//       g++ -g c2.cpp ; ./a.exe

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace         std;

#define                 int long long

#define                 pb push_back

#define                 mp make_pair

#define st(arr,a)       memset(arr,a,sizeof arr)

#define                 nl cout<<endl

#define                 real signed

#define                 endl '\n'              

#define bitcount(x)     __builtin_popcountll(x)

const int MOD = 1000000007ll;

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

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

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

#define pi pair<int,int>

#define X first

#define Y second

#define N 1014159

#define  vi vector<int>

#define  v  vector





int n,h[N];

int dp[N];



void solve()

{

    cin>>n;

    forn(i,1,n)cin>>h[i];

    dp[1] = 0;

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

    forn(i,3,n)

    {

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

    }

    cout<<dp[n];

    

}





signed main() 

{

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 

    int t = 1;

    //cin>>t;

    while(t--)

    {

        solve();

    }







    return 0;



}



//       g++ -g c.cpp ; ./a.exe

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



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



const long long INF = 1LL << 60;



using namespace std;



int main() {



    long int n; cin >> n;

    long int h[n]; rep(i,n) cin >> h[i];



    long long dp[100010]; rep(i,100010) dp[i] = INF;



    dp[0] = 0;

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



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



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



    }



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



    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



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



const int INF = 1001001001;



using namespace std;



int main() {



    int n; cin >> n;

    vector<int> h(n); rep(i,n) cin >> h[i];



    vector<int> dp(n,INF);



    dp[0] = 0;

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



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



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



    }



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



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

#pragma GCC optimize "03"

using namespace std;



#define int long long int

#define pb push_back

#define pii pair<int,int>

#define fi first

#define se second

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

#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }

#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }

#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }

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

#ifndef LOCAL

#define endl '\n'

#endif

const int inf = INT_MAX;

const double eps = 0.0000001;

const double PI = acos(-1.0);

const int MOD = 1e9+7;

const int N  = 1e5+5;



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



int solve (int i) {

	if (i > n) return inf;

	if (i == n) return 0;

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

	if (dp[i] >= 0) return dp[i];

	int ans = inf;

	for (auto j: {i+1, i+2}) {

		ans = min(ans, solve(j)+abs(a[j]-a[i]));

	}

	dp[i] = ans;

	return ans;

}



signed main(){

    #ifdef LOCAL

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

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

    #endif  

    IOS;



    cin >> n;

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

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

    	cin >> a[i];

    cout << solve(1);

    return 0;

}

// Optimized solution to the same problem (faster):
#include "bits/stdc++.h"

#pragma GCC optimize "03"

using namespace std;



#define int long long int

#define pb push_back

#define pii pair<int,int>

#define fi first

#define se second

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

#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }

#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }

#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }

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

#ifndef LOCAL

#define endl '\n'

#endif



const int inf = INT_MAX;

const int MOD = 1e9 + 7;

const int N = 1e5 + 5;



int a[N], dp[N];



signed main(){

    IOS;

    int n;

    cin >> n;

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

        cin >> a[i];

    dp[1] = 0;

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

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

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

    cout << dp[n] << endl;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define INF 0x3f3f3f3f

int n, k, v[100005], tab[100005];

int knap(int obj){

    if(tab[obj]!=INF){

        return tab[obj];

    }

    if(obj==n){

        return tab[obj]=0;

    }

    if(obj>n){

        return tab[obj]=INF;

    }

    return tab[obj]=min(abs(v[obj]-v[obj+1])+knap(obj+1), abs(v[obj]-v[obj+2])+knap(obj+2));

}

int main()

{

    memset(tab, INF, sizeof(tab));

    cin >> n;

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

        cin >> v[i];

    }

    cout << knap(1) << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

#define INF 0x3f3f3f3f

int n, val[100005], dp[100005];

int main()

{

    cin >> n;

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

        cin >> val[i];

    }

    dp[1]=0;

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

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

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

    }

    cout << dp[n] << endl;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):


/**

 *    Coded by : lucky_21

 *               --------Lokesh Singh

**/



#include<bits/stdc++.h>

using namespace std;



#include <ext/pb_ds/tree_policy.hpp>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define     F           first

#define     S           second

#define     pb          push_back

#define     lb          lower_bound

#define     ub          upper_bound

#define     pii         pair<int,int>

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

#define     fix         fixed<<setprecision(10)

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

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

#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)



typedef double db;

typedef long long ll;



const int N=1e5+5;

const int mod=1e9+7;



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

int rec(int i,int last){

    if(i>n) return 1e9;

    if(i==n) return abs(h[i]-(last?h[i-2]:h[i-1]));

    int &cache=dp[i][last];

    if(cache!=-1) return cache;

    return cache=abs(h[i]-(last?h[i-2]:h[i-1]))+min(rec(i+1,0),rec(i+2,1));

}

signed main(){

    FastIO;

    cin>>n;

    rep(i,1,n) cin>>h[i];

    memset(dp,-1,sizeof dp);

    h[0]=h[1];

    cout<<rec(1,0);

    return 0;

}


// Optimized solution to the same problem (faster):


/**

 *    Coded by : lucky_21

 *               --------Lokesh Singh

**/



#include<bits/stdc++.h>

using namespace std;



#include <ext/pb_ds/tree_policy.hpp>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define     F           first

#define     S           second

#define     pb          push_back

#define     lb          lower_bound

#define     ub          upper_bound

#define     pii         pair<int,int>

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

#define     fix         fixed<<setprecision(10)

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

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

#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)



typedef double db;

typedef long long ll;



const int N=1e5+5;

const int mod=1e9+7;



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

signed main(){

    FastIO;

    cin>>n;

    rep(i,1,n) cin>>h[i];

    rep(i,2,n){

        dp[i]=2e9;

        rep(j,1,2){

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

        }

    }

    cout<<dp[n];

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#include<stdio.h>

 

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

#define rep(i,n) FOR(i,0,n)

#define f first

#define s second

#define pb push_back

#define mp make_pair

#define INF 1000000000000000

#define MAXN (int)(1e6)+1

#define MOD 1000000007

 

using namespace std;

 

typedef long long int lli;

typedef pair<int,int> pii;

typedef pair<lli,int> pwi;

typedef pair<lli,lli> plli;

typedef vector<int> vi;

typedef vector<lli> vlli;

typedef vector< vector<pair<int,lli > > > wGraph;

typedef vector<vector<int> > graph;

//typedef vector<vector<int> > matrix;



int n;

int dp[MAXN];

vi ar;



int knap(int ind){

    

    if(ind>=n){

        return 0;

    }

    

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

    

    int takeIt = INT_MAX,leaveIt = INT_MAX;

    if(ind+2 < n){

        takeIt = abs(ar[ind]-ar[ind+2]);

    }

    if(ind+1<n)

        leaveIt = abs(ar[ind]-ar[ind+1]);

    

    if(ind+1>=n) return dp[ind] = 0;

    else{

        return dp[ind] = min(takeIt+knap(ind+2),leaveIt+knap(ind+1));

    }

    

}





int main(){

 

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    cout<<std::fixed;

    cout<<std::setprecision(4);

    

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

        dp[i] = -1;

    }

    

    cin>>n;

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

        int v;

        cin>>v;

        ar.pb(v);

    }   

    

    cout<<knap(0)<<endl;

    

    return 0;

 

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#include<stdio.h>

 

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

#define rep(i,n) FOR(i,0,n)

#define f first

#define s second

#define pb push_back

#define mp make_pair

#define INF 1000000000000000

#define MAXN (int)(1e6)+1

#define MOD 1000000007

 

using namespace std;

 

typedef long long int lli;

typedef pair<int,int> pii;

typedef pair<lli,int> pwi;

typedef pair<lli,lli> plli;

typedef vector<int> vi;

typedef vector<lli> vlli;

typedef vector< vector<pair<int,lli > > > wGraph;

typedef vector<vector<int> > graph;

//typedef vector<vector<int> > matrix;



int main(){

 

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    cout<<std::fixed;

    cout<<std::setprecision(4);

    

    int n;

    cin>>n;

    

    vi ar;

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

        int v;

        cin>>v;

        ar.pb(v);

    }   

    

    int dp[n+1];

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

        

        if(i == 0){

            dp[i] = 0;

        }else if(i == 1){

            dp[i] = abs(ar[i]-ar[i-1]);    

        }else{

            

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

                        dp[i-2]+abs(ar[i]-ar[i-2]));    

            

        }

        

    }

    

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

       

    return 0;

 

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

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

#define ld long double

#define ll long long

#define pb push_back

#define pi acos(-1)

#define eps 1e-7

#define F first

#define S second

#define X real()

#define Y imag()

#define cross(a,b) (conj(a)*(b)).X

#define dot(a,b) (conj(a)*(b)).Y

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

#define allr(f) (f).rbegin(),(f).rend()

const int mod = 1e9+7 , A = 1e5 ;

typedef complex <ld> point ;

typedef vector <point> polygon ;

typedef tuple <int , int , int> line ;

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

ll n , ans[100005] , h[100005] ;

ll solve(ll ind)

{

	if (ind >= n)

		return 1e10 ;

	if (ind == n-1)

		return 0 ;

	if (ans[ind] != -1)

		return ans[ind] ;

	ll val = 1e10 ;

	val = min(val , abs(h[ind] - h[ind+1]) + solve(ind+1)) ;

	val = min(val , abs(h[ind] - h[ind+2]) + solve(ind+2)) ;

	ans[ind] = val ;

	return val ;

}

int main()

{

	_K

	cin >> n ;

	memset(ans , -1 , sizeof ans) ;

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

	cout << solve(0) ;

	return 0 ;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

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

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

#define BiEdge(v,a,b) (v)[(a)].pb((b)),(v)[(b)].pb((a))

#define ll long long

#define ld long double

#define pb push_back

#define Pb pop_back

#define F first

#define S second

#define X real()

#define Y imag()

#define pi acos(-1)

#define eps 1e-7

#define bpc __builtin_popcount

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

#define allr(f) (f).rbegin(),(f).rend()

#define cross(a,b) (conj(a)*(b)).real()

#define dot(a,b) (conj(a)*(b)).imag()

typedef complex <ld> point ;

typedef vector <point> polygon ;

typedef tuple <ll,ll,ll> line ;

const int mod = 1e9+7 , A = 1e9+1 ;



int main()

{

	ios

	ll n ; cin >> n ;

	ll a[n] , dp[n] ;

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

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

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

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

	cout << dp[n-1] ;

	return 0 ;

}


// Fastest known solution for this problem: