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

//freopen("transmitters.in","r",stdin);

//cout<<fixed<<setprecision(6)<<n<<endl;

// transform(s.begin(), s.end(), s.begin(), ::tolower);

//double PI=3.14159265359,c=0;

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

#define endl '\n'

#define ll long long

//#define f(n) for(int i=;i<n;i++)

double PI = acos(-1);

using namespace std;

void fast()

{

	std::ios_base::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);

}

int arr[1000005], n;

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

int minCost(int indx)

{

	int path1=INT_MAX, path2=INT_MAX;

	if (indx == n - 1)

		return 0;



	if (v[indx] != -1)

		return v[indx];



	if (indx + 1 < n)

		path1 = abs(arr[indx] - arr[indx + 1]) + minCost(indx + 1);



	if (indx + 2 < n)

		path2 = abs(arr[indx] - arr[indx + 2]) + minCost(indx + 2);



	return v[indx] = min(path1, path2);

}

int main()

{

	fast();

	cin >> n;

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

		cin >> arr[i];



	cout << minCost(0) << endl;



	return 0;

}

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

using namespace std;

typedef long long int lli;

typedef unsigned long long int ull;



lli dp[100005];



lli solve(lli ara[], int i, int n) {

    cout<<i<<": "<<endl;

    lli ans1=LONG_LONG_MAX, ans2=LONG_LONG_MAX;

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

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

    if(i+1<n){

        if(dp[i+1] == -1) dp[i+1] = abs(ara[i] - ara[i+1]) + solve(ara, i+1, n);

        ans1 = dp[i+1];

    }

    if(i+2<n){

        if(dp[i+2] == -1) dp[i+2] = abs(ara[i] - ara[i+2]) + solve(ara, i+2, n);

        ans2 = dp[i+2];

    }

    lli ans = min(ans1, ans2);

    printf("I: %d, ans1 = %lld, ans2 = %lld, ans = %lld\n", i, ans1, ans2, ans);

    return ans;

}



int main(){

    int T=1, cs=1;

    //scanf("%d", &T);

    while(T--){



        int n;

        scanf("%d", &n);

        memset(dp, -1, 100005);

        lli ara[n+2];

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

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

        }

        //cout<<solve(ara, 0, n)<<endl;

        lli ans[n+2];

        ans[n-1] = 0;

        ans[n-2] = abs(ara[n-1] - ara[n-2]);

        for(int i=n-3; i>=0; i--){

            lli ans1 = abs(ara[i] - ara[i+1]) + ans[i+1];

            lli ans2 = abs(ara[i] - ara[i+2]) + ans[i+2];

            ans[i] = min(ans1, ans2);

        }



        //for(int i=0; i<n; i++) cout<<"ans "<<i<<": "<<ans[i]<<endl;

        cout<<ans[0]<<endl;

    }



    return 0;

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

using namespace std;



const int N=1e5+30;

typedef long long ll;

int n,arr[N];

int dp[N];

ll solve(int i){

    if(i>=n)return 1e15;

    if(i==n-1){

        return 0;

    }



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



    ll path1=abs(arr[i]-arr[i+1])+solve(i+1);

    ll path2=abs(arr[i]-arr[i+2])+solve(i+2);

    return dp[i]= min(path1,path2);

}

int main()

{

    memset(dp,-1,sizeof dp);

    scanf("%d",&n);

    for(int i=0;i<n;i++)scanf("%d",arr+i);

    cout<<solve(0)<<endl;

}




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

using namespace std;

typedef long long int lli;

typedef unsigned long long int ull;



lli dp[100005];



lli solve(lli ara[], int i, int n) {

    cout<<i<<": "<<endl;

    lli ans1=LONG_LONG_MAX, ans2=LONG_LONG_MAX;

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

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

    if(i+1<n){

        if(dp[i+1] == -1) dp[i+1] = abs(ara[i] - ara[i+1]) + solve(ara, i+1, n);

        ans1 = dp[i+1];

    }

    if(i+2<n){

        if(dp[i+2] == -1) dp[i+2] = abs(ara[i] - ara[i+2]) + solve(ara, i+2, n);

        ans2 = dp[i+2];

    }

    lli ans = min(ans1, ans2);

    printf("I: %d, ans1 = %lld, ans2 = %lld, ans = %lld\n", i, ans1, ans2, ans);

    return ans;

}



int main(){

    int T=1, cs=1;

    //scanf("%d", &T);

    while(T--){



        int n;

        scanf("%d", &n);

        memset(dp, -1, 100005);

        lli ara[n+2];

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

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

        }

        //cout<<solve(ara, 0, n)<<endl;

        lli ans[n+2];

        ans[n-1] = 0;

        ans[n-2] = abs(ara[n-1] - ara[n-2]);

        for(int i=n-3; i>=0; i--){

            lli ans1 = abs(ara[i] - ara[i+1]) + ans[i+1];

            lli ans2 = abs(ara[i] - ara[i+2]) + ans[i+2];

            ans[i] = min(ans1, ans2);

        }



        //for(int i=0; i<n; i++) cout<<"ans "<<i<<": "<<ans[i]<<endl;

        cout<<ans[0]<<endl;

    }



    return 0;

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

using namespace std;

typedef long long int lli;

typedef unsigned long long int ull;



lli dp[100005];



lli solve(lli ara[], int i, int n) {

    cout<<i<<": "<<endl;

    lli ans1=LONG_LONG_MAX, ans2=LONG_LONG_MAX;

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

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

    if(i+1<n){

        if(dp[i+1] == -1) dp[i+1] = abs(ara[i] - ara[i+1]) + solve(ara, i+1, n);

        ans1 = dp[i+1];

    }

    if(i+2<n){

        if(dp[i+2] == -1) dp[i+2] = abs(ara[i] - ara[i+2]) + solve(ara, i+2, n);

        ans2 = dp[i+2];

    }

    lli ans = min(ans1, ans2);

    printf("I: %d, ans1 = %lld, ans2 = %lld, ans = %lld\n", i, ans1, ans2, ans);

    return ans;

}



int main(){

    int T=1, cs=1;

    //scanf("%d", &T);

    while(T--){



        int n;

        scanf("%d", &n);

        memset(dp, -1, 100005);

        lli ara[n+2];

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

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

        }

        //cout<<solve(ara, 0, n)<<endl;

        lli ans[n+2];

        ans[n-1] = 0;

        ans[n-2] = abs(ara[n-1] - ara[n-2]);

        for(int i=n-3; i>=0; i--){

            lli ans1 = abs(ara[i] - ara[i+1]) + ans[i+1];

            lli ans2 = abs(ara[i] - ara[i+2]) + ans[i+2];

            ans[i] = min(ans1, ans2);

        }



        //for(int i=0; i<n; i++) cout<<"ans "<<i<<": "<<ans[i]<<endl;

        cout<<ans[0]<<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.6550045202455754x):
#include <bits/stdc++.h>

using namespace std;

typedef long long int lli;

typedef unsigned long long int ull;



lli dp[100005];



lli solve(lli ara[], int i, int n) {

    cout<<i<<": "<<endl;

    lli ans1=LONG_LONG_MAX, ans2=LONG_LONG_MAX;

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

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

    if(i+1<n){

        if(dp[i+1] == -1) dp[i+1] = abs(ara[i] - ara[i+1]) + solve(ara, i+1, n);

        ans1 = dp[i+1];

    }

    if(i+2<n){

        if(dp[i+2] == -1) dp[i+2] = abs(ara[i] - ara[i+2]) + solve(ara, i+2, n);

        ans2 = dp[i+2];

    }

    lli ans = min(ans1, ans2);

    printf("I: %d, ans1 = %lld, ans2 = %lld, ans = %lld\n", i, ans1, ans2, ans);

    return ans;

}



int main(){

    int T=1, cs=1;

    //scanf("%d", &T);

    while(T--){



        int n;

        scanf("%d", &n);

        memset(dp, -1, 100005);

        lli ara[n+2];

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

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

        }

        //cout<<solve(ara, 0, n)<<endl;

        lli ans[n+2];

        ans[n-1] = 0;

        ans[n-2] = abs(ara[n-1] - ara[n-2]);

        for(int i=n-3; i>=0; i--){

            lli ans1 = abs(ara[i] - ara[i+1]) + ans[i+1];

            lli ans2 = abs(ara[i] - ara[i+2]) + ans[i+2];

            ans[i] = min(ans1, ans2);

        }



        //for(int i=0; i<n; i++) cout<<"ans "<<i<<": "<<ans[i]<<endl;

        cout<<ans[0]<<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.6484067261566975x):
#include <bits/stdc++.h>

using namespace std;

typedef long long int lli;

typedef unsigned long long int ull;



lli dp[100005];



lli solve(lli ara[], int i, int n) {

    cout<<i<<": "<<endl;

    lli ans1=LONG_LONG_MAX, ans2=LONG_LONG_MAX;

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

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

    if(i+1<n){

        if(dp[i+1] == -1) dp[i+1] = abs(ara[i] - ara[i+1]) + solve(ara, i+1, n);

        ans1 = dp[i+1];

    }

    if(i+2<n){

        if(dp[i+2] == -1) dp[i+2] = abs(ara[i] - ara[i+2]) + solve(ara, i+2, n);

        ans2 = dp[i+2];

    }

    lli ans = min(ans1, ans2);

    printf("I: %d, ans1 = %lld, ans2 = %lld, ans = %lld\n", i, ans1, ans2, ans);

    return ans;

}



int main(){

    int T=1, cs=1;

    //scanf("%d", &T);

    while(T--){



        int n;

        scanf("%d", &n);

        memset(dp, -1, 100005);

        lli ara[n+2];

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

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

        }

        //cout<<solve(ara, 0, n)<<endl;

        lli ans[n+2];

        ans[n-1] = 0;

        ans[n-2] = abs(ara[n-1] - ara[n-2]);

        for(int i=n-3; i>=0; i--){

            lli ans1 = abs(ara[i] - ara[i+1]) + ans[i+1];

            lli ans2 = abs(ara[i] - ara[i+2]) + ans[i+2];

            ans[i] = min(ans1, ans2);

        }



        //for(int i=0; i<n; i++) cout<<"ans "<<i<<": "<<ans[i]<<endl;

        cout<<ans[0]<<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.3776596469772886x):
#include <bits/stdc++.h>

using namespace std;

typedef long long int lli;

typedef unsigned long long int ull;



lli dp[100005];



lli solve(lli ara[], int i, int n) {

    cout<<i<<": "<<endl;

    lli ans1=LONG_LONG_MAX, ans2=LONG_LONG_MAX;

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

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

    if(i+1<n){

        if(dp[i+1] == -1) dp[i+1] = abs(ara[i] - ara[i+1]) + solve(ara, i+1, n);

        ans1 = dp[i+1];

    }

    if(i+2<n){

        if(dp[i+2] == -1) dp[i+2] = abs(ara[i] - ara[i+2]) + solve(ara, i+2, n);

        ans2 = dp[i+2];

    }

    lli ans = min(ans1, ans2);

    printf("I: %d, ans1 = %lld, ans2 = %lld, ans = %lld\n", i, ans1, ans2, ans);

    return ans;

}



int main(){

    int T=1, cs=1;

    //scanf("%d", &T);

    while(T--){



        int n;

        scanf("%d", &n);

        memset(dp, -1, 100005);

        lli ara[n+2];

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

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

        }

        //cout<<solve(ara, 0, n)<<endl;

        lli ans[n+2];

        ans[n-1] = 0;

        ans[n-2] = abs(ara[n-1] - ara[n-2]);

        for(int i=n-3; i>=0; i--){

            lli ans1 = abs(ara[i] - ara[i+1]) + ans[i+1];

            lli ans2 = abs(ara[i] - ara[i+2]) + ans[i+2];

            ans[i] = min(ans1, ans2);

        }



        //for(int i=0; i<n; i++) cout<<"ans "<<i<<": "<<ans[i]<<endl;

        cout<<ans[0]<<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.2737566416499897x):
#include <bits/stdc++.h>

using namespace std;

typedef long long int lli;

typedef unsigned long long int ull;



lli dp[100005];



lli solve(lli ara[], int i, int n) {

    cout<<i<<": "<<endl;

    lli ans1=LONG_LONG_MAX, ans2=LONG_LONG_MAX;

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

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

    if(i+1<n){

        if(dp[i+1] == -1) dp[i+1] = abs(ara[i] - ara[i+1]) + solve(ara, i+1, n);

        ans1 = dp[i+1];

    }

    if(i+2<n){

        if(dp[i+2] == -1) dp[i+2] = abs(ara[i] - ara[i+2]) + solve(ara, i+2, n);

        ans2 = dp[i+2];

    }

    lli ans = min(ans1, ans2);

    printf("I: %d, ans1 = %lld, ans2 = %lld, ans = %lld\n", i, ans1, ans2, ans);

    return ans;

}



int main(){

    int T=1, cs=1;

    //scanf("%d", &T);

    while(T--){



        int n;

        scanf("%d", &n);

        memset(dp, -1, 100005);

        lli ara[n+2];

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

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

        }

        //cout<<solve(ara, 0, n)<<endl;

        lli ans[n+2];

        ans[n-1] = 0;

        ans[n-2] = abs(ara[n-1] - ara[n-2]);

        for(int i=n-3; i>=0; i--){

            lli ans1 = abs(ara[i] - ara[i+1]) + ans[i+1];

            lli ans2 = abs(ara[i] - ara[i+2]) + ans[i+2];

            ans[i] = min(ans1, ans2);

        }



        //for(int i=0; i<n; i++) cout<<"ans "<<i<<": "<<ans[i]<<endl;

        cout<<ans[0]<<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.2737566416499897x):
#include <bits/stdc++.h>

using namespace std;

typedef long long int lli;

typedef unsigned long long int ull;



lli dp[100005];



lli solve(lli ara[], int i, int n) {

    cout<<i<<": "<<endl;

    lli ans1=LONG_LONG_MAX, ans2=LONG_LONG_MAX;

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

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

    if(i+1<n){

        if(dp[i+1] == -1) dp[i+1] = abs(ara[i] - ara[i+1]) + solve(ara, i+1, n);

        ans1 = dp[i+1];

    }

    if(i+2<n){

        if(dp[i+2] == -1) dp[i+2] = abs(ara[i] - ara[i+2]) + solve(ara, i+2, n);

        ans2 = dp[i+2];

    }

    lli ans = min(ans1, ans2);

    printf("I: %d, ans1 = %lld, ans2 = %lld, ans = %lld\n", i, ans1, ans2, ans);

    return ans;

}



int main(){

    int T=1, cs=1;

    //scanf("%d", &T);

    while(T--){



        int n;

        scanf("%d", &n);

        memset(dp, -1, 100005);

        lli ara[n+2];

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

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

        }

        //cout<<solve(ara, 0, n)<<endl;

        lli ans[n+2];

        ans[n-1] = 0;

        ans[n-2] = abs(ara[n-1] - ara[n-2]);

        for(int i=n-3; i>=0; i--){

            lli ans1 = abs(ara[i] - ara[i+1]) + ans[i+1];

            lli ans2 = abs(ara[i] - ara[i+2]) + ans[i+2];

            ans[i] = min(ans1, ans2);

        }



        //for(int i=0; i<n; i++) cout<<"ans "<<i<<": "<<ans[i]<<endl;

        cout<<ans[0]<<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.7752776503877752x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define  pb push_back





///shortcuts

///ctr+alr+T



int main(void)

{

    ios::sync_with_stdio(false);

    cin.tie(0);





    int n; cin>>n;

    vector<int>h(n);



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

        cin>>h[i];

    }



    vector<int>cost(n,1e9+5);



    cost[0] = 0;

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



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

        if(i<n-2)

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





       /* cout<<i<<endl;

        cout<<cost[i]<<endl;

        cout<<"1: "<<cost[i+1]<<endl;

        if(i<n-2)

        cout<<"2: "<<cost[i+2]<<endl;*/

    }





    cout<<cost[n-1]<<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.3957777300733487x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define  pb push_back





///shortcuts

///ctr+alr+T



int main(void)

{

    ios::sync_with_stdio(false);

    cin.tie(0);





    int n; cin>>n;

    vector<int>h(n);



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

        cin>>h[i];

    }



    vector<int>cost(n,1e9+5);



    cost[0] = 0;

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



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

        if(i<n-2)

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





       /* cout<<i<<endl;

        cout<<cost[i]<<endl;

        cout<<"1: "<<cost[i+1]<<endl;

        if(i<n-2)

        cout<<"2: "<<cost[i+2]<<endl;*/

    }





    cout<<cost[n-1]<<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.3801718892141153x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define  pb push_back





///shortcuts

///ctr+alr+T



int main(void)

{

    ios::sync_with_stdio(false);

    cin.tie(0);





    int n; cin>>n;

    vector<int>h(n);



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

        cin>>h[i];

    }



    vector<int>cost(n,1e9+5);



    cost[0] = 0;

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



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

        if(i<n-2)

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





       /* cout<<i<<endl;

        cout<<cost[i]<<endl;

        cout<<"1: "<<cost[i+1]<<endl;

        if(i<n-2)

        cout<<"2: "<<cost[i+2]<<endl;*/

    }





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







}