stablegradients/pie-gem5-pairs huggingface dataset:
// 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.7509331620317288x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

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

template <typename Arg1>

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

	cerr << name << " : " << arg1 << 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...);

}



#define ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

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

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



	rep(i, n) cin >> vv[i];



	dp[n] = 0;



	for (int i = n - 1; i >= 1; i--)

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



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

using namespace std;

#define ll long long int

#define dbl double

#define pi acos(-1)

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

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

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

#define pb push_back



ll ara[1000005];



map<ll,ll>vis;

map<ll,ll>vis1;

map<ll,ll>pos;

map<ll,ll>high;

map<ll,ll>low;

map<string,ll>mp;

vector<ll>vec;

vector<ll>v;

stack<ll>q;

string str1[100];

string str2[100];

priority_queue<ll>pq;

ll dp[1000005],t;

ll mn=1000000;

ll call(ll id)

{

    if(id==t )return 0;

    if(dp[id]!=-1)

        return dp[id];

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

    ll q=100000000;

    if(id+2!=t+1)

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

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

    return dp[id];



}

int main()

{



    // ll t;

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

    sc1(t);

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

    {

        sc1(ara[i]);

    }

    cout<<call(1)<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 9.205324033556561x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

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

template <typename Arg1>

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

	cerr << name << " : " << arg1 << 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...);

}



#define ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

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

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



	rep(i, n) cin >> vv[i];



	dp[n] = 0;



	for (int i = n - 1; i >= 1; i--)

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



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



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

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

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

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

#define pb push_back

#define eb emplace_back

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

#define F first

#define S second

#define endl '\n'

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

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



using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;

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



const int N=1e5+5;

int dp[N];

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

	int n;

	cin>>n;

	vector<int> a(n);

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

	ms(dp,INF);

	dp[0]=0;

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

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

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

	}

	cout<<dp[n-1];

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 1.3990641804400317x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

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

template <typename Arg1>

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

	cerr << name << " : " << arg1 << 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...);

}



#define ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

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

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



	rep(i, n) cin >> vv[i];



	dp[n] = 0;



	for (int i = n - 1; i >= 1; i--)

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



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

using namespace std;



int a[1000001];

int dp[1000001];

int it;



int fr(int p){

	if (p==it-1){

      return 0;

    }

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

      return dp[p];

    }

	int re=abs(a[p]-a[p+1])+fr(p+1);

	if(p!=it-2){

      re=min(re,abs(a[p]-a[p+2])+fr(p+2));

    }

	return dp[p]=re;

}

int main(){

	cin>>it;

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

    cin>>a[i];

    }



	memset(dp,-1,sizeof dp);

	cout<<fr(0)<<endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.97407889700543x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

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

template <typename Arg1>

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

	cerr << name << " : " << arg1 << 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...);

}



#define ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

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

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



	rep(i, n) cin >> vv[i];



	dp[n] = 0;



	for (int i = n - 1; i >= 1; i--)

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



}
// Slower C++ solution:


#include <iostream>

#include <bits/stdc++.h>





using namespace std;





int a[100005], p[100005],n, i;

int respuesta(int x)

{

    if(x==n) return 0;

    if(x>n) return 1e9;

    if(p[x]!=-1)return p[x];

    return p[x]=min(abs(a[x+1]-a[x])+respuesta(x+1), abs(a[x+2]-a[x])+respuesta(x+2));

}





int main()

{

    memset(p,-1,sizeof p);

    cin>>n;

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

    {

        cin>>a[i];

    }

    cout<<respuesta(1)<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.373460500778428x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

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

template <typename Arg1>

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

	cerr << name << " : " << arg1 << 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...);

}



#define ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

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

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



	rep(i, n) cin >> vv[i];



	dp[n] = 0;



	for (int i = n - 1; i >= 1; i--)

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



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

using namespace std;

typedef long long ll;

typedef long long int lli;

typedef long double ld;

const int oo = 1e9;

const int mod = 1e9+9;

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

const int nax = 1e5+3;

int n;

int dp[nax];

int a[nax];

int f(int i){

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

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

	int ans = abs(a[i]-a[i+1])+f(i+1);

	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));

	return dp[i]=ans;

}

int main(){

	cin>>n;

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

	memset(dp, -1, sizeof dp);

	cout<<f(0)<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3704332030763309x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

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

template <typename Arg1>

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

	cerr << name << " : " << arg1 << 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...);

}



#define ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

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

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



	rep(i, n) cin >> vv[i];



	dp[n] = 0;



	for (int i = n - 1; i >= 1; i--)

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



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

using namespace std;

typedef long long ll;

typedef long long int lli;

typedef long double ld;

const int oo = 1e9;

const int mod = 1e9+9;

/*ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }

*ll lcm(ll x, ll y){return x*(y/gcd(x,y));}

*void exEuclid(int a, int b){

	if(b==0){x = 1; y=0; d=a; return ;}

	exEuclid(b, a%b);

	int x1=y;

	int y1=x-(a/b)*y;

	x=x1;

	y=y1;

} 

* */

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

const int nax = 1e5+3;

int n;

int dp[nax];

int a[nax];

int f(int i){

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

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

	int ans = abs(a[i]-a[i+1])+f(i+1);

	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));

	return dp[i]=ans;

}

int main(){

	cin>>n;

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

	memset(dp, -1, sizeof dp);

	cout<<f(0)<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3704332030763309x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

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

template <typename Arg1>

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

	cerr << name << " : " << arg1 << 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...);

}



#define ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

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

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



	rep(i, n) cin >> vv[i];



	dp[n] = 0;



	for (int i = n - 1; i >= 1; i--)

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



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

using namespace std;

typedef long long ll;

ll dp[100009];

int arr[100009];

ll sum = 0;

long long Frog1(int n){

 

    if(n==0) return 0;

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

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

    else {

            ll x = Frog1(n-1);

            ll y = Frog1(n-2);

        dp[n] = min(abs (arr[n-1] - arr[n]) + x,abs(arr[n-2] - arr[n]) + y);

        //cout << n << " = " << dp[n] << endl;

         return dp[n];

    }

}

 

 

int main()

{

    int n;

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

    cin >> n;

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

    cout << Frog1(n-1) << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.763767869353693x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

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

template <typename Arg1>

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

	cerr << name << " : " << arg1 << 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...);

}



#define ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

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

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



	rep(i, n) cin >> vv[i];



	dp[n] = 0;



	for (int i = n - 1; i >= 1; i--)

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



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

using namespace std;

#define ll long long

#define ld long double

#define sf scanf

#define pf printf

#define pb push_back

#define llu unsigned long long

#define U unsigned int

#define SIZE 1000002

#define pie 3.14159265358979323

#define minuss 1e-6

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

 

#define BIG 100000000

 

ll  lcm(ll a,ll b)

{

    ll GCD=__gcd(a,b);

    ll lcm=(a*b)/GCD;

    return lcm;

}

ll dp[100005];

ll weight[1000005],value[1000005];

ll total,val;

ll call(ll n)

{

    if(n>=total)

        return 0;

 

    if(dp[n]!=-1)

        return dp[n];

 

    ll res1=BIG,res2=BIG;

 

   // if(weight[n]+c<=val)

    res1=abs(weight[n]-weight[n+1]) + call(n+1);

    if(n+2<=total) res2=abs(weight[n]-weight[n+2]) + call(n+2);

    //cout<<n<<" "<<res1<<" "<<res2<<endl;

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

    return dp[n];

 

}

int main()

{

    cin>>total;

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

        cin>>weight[i];

 

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

    ll ret=call(1);

    cout<<ret<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7631065788490417x):
#pragma GCC optimize ("Ofast")

#include"bits/stdc++.h"

using namespace std;



//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;



struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;

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

template <typename Arg1>

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

	cerr << name << " : " << arg1 << 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...);

}



#define ll long long

#define pii pair<int,int>

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first

#define ss second

#define endll '\n'

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

#define scl(i) scanf("%lld",&i)

#define int long long int

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

#define mem(n,i) memset(n,i,sizeof n)

#define em(a) emplace_back(a)

#define pb(a) push_back(a)

#define srep(it,vv) for(auto &it : vv)

#define prep(it,vv) for(auto it : vv)

//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));



typedef vector<int> vii;

typedef vector<string> vss;

/*



*/

signed main()

{



	int n; cin >> n;

	std::vector<int> vv(n + 5);

	std::vector<int> dp(n + 5);



	rep(i, n) cin >> vv[i];



	dp[n] = 0;



	for (int i = n - 1; i >= 1; i--)

	{

		int x1 = dp[i + 1] + abs(vv[i] - vv[i + 1]);

		int x2 = INT_MAX;

		if (i + 2 <= n) x2 = dp[i + 2] + abs(vv[i] - vv[i + 2]);

		dp[i] = min(x1, x2);

	}

	cout << dp[1] << endll;



}