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

using namespace std;



int num[100001], memo[100001];



int dp(int n){

    if(n==0) return 0;

    if(n==1) return abs(num[0]-num[1]);

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

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

}



int main(){

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

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

    ios_base::sync_with_stdio(0);

    cin.tie(0);

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

    int n;

    cin>>n;

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

    cout<<dp(n-1)<<"\n";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3799286390180363x):
#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 v[100010];

int memo[100010];

int c;



int f(int i)

{



    if(memo[i]!=-1)

        return memo[i];



    if(i == 0)

        return memo[0] = 0;



    if(i == 1)

        return memo[1] = abs(v[0] - v[1]);



    return memo[i] = min(abs(v[i] - v[i-1]) + f(i-1), abs(v[i] - v[i-2]) + f(i-2));

}



int main()

{



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

    cin>>c;



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

    {

        cin>>v[i];

    }



    cout<<f(c-1)<<endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3657669788701083x):
#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;



const int N = 1e5 + 9;



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



int solve(int i){

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

    if(i == n)   return 1e9;



    int &ret = dp[i];

    if(~ret)    return ret;



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

}



int main(){



    cin >> n;

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

        cin >> h[i];



    memset(dp, -1, sizeof dp);



    cout << solve(0);

}


// Faster C++ solution for the same problem (measured speedup: 1.3687438232316425x):
#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 n;

long long h[100005];

long long dp[100005];



long long solve(int i){

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

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



	dp[i] = 1e17;

	if(i+1 <= n-1)

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

	if(i+2 <= n-1)

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



	return dp[i];

}



int main(){

	scanf("%d", &n);

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

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

	memset(dp, -1, sizeof dp);

	cout<<solve(0)<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7636864005633612x):
#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 pb push_back

#define mp make_pair

#define ull  unsigned long long

#define vll  vector <long long>

#define pll pair <long long,long long>

#define f first

#define s second

#define up upper_bound

#define lp lower_bound

#define pq priority_queue

#define inf 1e10

#define minf -1e10

#define pi 3.14159265

#define mod 300000000000000000

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);

int main()

{

    ll n;

    cin>>n;

    vll vec;

    ll ara[100001];

    memset(ara,0,sizeof(ara));

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

    {

        ll num;

        cin>>num;

        vec.pb(num);

    }

    ll ans=0;

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

    for(ll i=n-3;i>=0;i--)

    {

        ara[i]=min(abs(vec[i]-vec[i+1])+ara[i+1],abs(vec[i]-vec[i+2])+ara[i+2]);

    }

    cout<<ara[0]<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.775702963013332x):
#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 ara[100000];

int dp[100000];



int f(int i, int n)

{

    if(i == n) return 0;

    if(dp[i] != -1)

        return dp[i];

    int cost = f(i+1,n) + abs(ara[i] - ara[i+1]);

    if(i+2<=n)

        cost = min(cost, f(i+2,n)+abs(ara[i] - ara[i+2]));

    dp[i] = cost;



    return cost;

}



int main()

{

   int n;

   cin>>n;



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

   {

       cin>>ara[i];

   }



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

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



   return 0;

}






// Faster C++ solution for the same problem (measured speedup: 1.3705527169242193x):
#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 TR 100000



int l[TR];

using namespace std;

vector<int> h;





int solve(int p) {

	if(p == 0)

		return 0;

	if(p < 0)

		return 10000000;

	if(l[p] != -1)

		return l[p];

	l[p] = min(abs(h[p] - h[p - 1]) + solve(p - 1), abs(h[p] - h[p - 2]) + solve(p - 2));

	return l[p];



}



int main() {

	int n;

	cin >> n;

	memset(l, -1, TR * sizeof(int));

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

		cin >> tmp;

		h.push_back(tmp);

	}

	solve(n - 1);

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

}

// Faster C++ solution for the same problem (measured speedup: 1.3731737537705473x):
#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 tam 100001

int dp[tam],A[tam],n,pr=0;

int solver(int index)

{

    if(dp[index] != -1)

        return dp[index];

    if(index <= 1)

        return dp[index] = abs(A[0]-A[index]);

    return dp[index] = min(solver(index-1) + abs(A[index]-A[index-1]),

    solver(index-2) + abs(A[index]-A[index-2]));

}

int main()

{

    cin>>n;

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

        cin>>A[i];

    memset(dp,-1,sizeof dp);

    dp[0] = 0; 

    cout<<solver(n-1)<<"\n";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3711504202362104x):
#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 INF 0x3f3f3f3f

using namespace std;

const int maxn = 1e6+10;

int a[maxn];

int dp[maxn];

int main()

{

    int n;

    memset(dp,INF,sizeof dp);

    scanf("%d",&n);

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

    {

        scanf("%d",a+i);

    }

    dp[1]=0;

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

    {

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

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

    }

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

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.957117110631615x):
#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;



const int mx=1e5+1;

int n,k;

int h[mx],dp[mx];

int solve(int s) //s->no of stone

{

    if(s==n) return 0;

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

    int ret=INT_MAX;

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

        if((i+s)<=n) ret=min(ret,abs(h[s+i]-h[s])+solve(s+i));

    }

    return dp[s]=ret;

}

int main()

{

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

    //freopen("input.txt","r",stdin);    return 0;



    cin>>n;

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

    memset(dp,-1,sizeof dp);

    cout<<solve(1);



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3823172992185888x):
#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;



}