stablegradients/pie-gem5-pairs huggingface dataset:
// 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: 5.020108740114919x):
#include<bits/stdc++.h>

using namespace std;

#define endl '\n'



const int N = 1e5;



int dp[N+5];

int arr[N+5];



int main(){



	ios_base::sync_with_stdio(0);

	int n; cin >>n;

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

	

	dp[0] = dp[1] = 0; arr[0] = arr[1];

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

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

	}

	

	cout <<dp[n] <<endl;

	return 0;

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

using namespace std;

#define endl '\n'



const int N = 1e5;



int dp[N+5];

int arr[N+5];



int main(){



	ios_base::sync_with_stdio(0);

	int n; cin >>n;

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

	

	dp[0] = dp[1] = 0; arr[0] = arr[1];

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

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

	}

	

	cout <<dp[n] <<endl;

	return 0;

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

using namespace std;

#define endl '\n'



const int N = 1e5;



int dp[N+5];

int arr[N+5];



int main(){



	ios_base::sync_with_stdio(0);

	int n; cin >>n;

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

	

	dp[0] = dp[1] = 0; arr[0] = arr[1];

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

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

	}

	

	cout <<dp[n] <<endl;

	return 0;

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

using namespace std;

#define N (int)2e5

int n,memo[N],c[N];



int dp(int curr) {

    if (curr == n) return 0;

    if (curr > n) return 1e9;

    int &sol = memo[curr];

    if (sol != -1) return sol;

    sol = min(

        dp(curr + 1) + abs(c[curr] - c[curr + 1]) ,

        dp(curr + 2) + abs(c[curr] - c[curr + 2])

    );

    return sol;

}



int main() {

    scanf("%d" , &n);

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

        scanf("%d" , &c[i]);

    memset (memo , -1 , sizeof memo);

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

}


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

    #define maxn 100000

    #define INF 1LL<<60

    using namespace std;

    long long h[maxn+3], dp[maxn+3];

    int n;



    long long solve(int cur){

        if(cur >= n) return INF;

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

        if(dp[cur]!= INF) return dp[cur];

        //long long res1 = INF, res2 = INF;

        long long res1 = solve(cur+1) + llabs(h[cur+1]-h[cur]);

        long long res2 = solve(cur+2) + llabs(h[cur+2]-h[cur]);

        return dp[cur] = min(res1, res2); 

    }



    int main() {

    	// your code goes here

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

    	while(scanf("%d",&n)==1){

            

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

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

                dp[i] = INF;

            }



            long long ans = solve(0);

            printf("%lld\n", ans);

        }

    }
// Slower C++ solution:
#include<set>

#include<map>

#include<cmath>

#include<ctime>

#include<queue>

#include<stack>

#include<cstdio>

#include<string>

#include<vector>

#include<random>

#include<cstdlib>

#include<cstring>

#include<iomanip>

#include<iostream>

#include<algorithm>

#include<unordered_map>

#define endl "\n"

#define fi first

#define se second

#define db double

#define gcd __gcd

#define pb push_back

#define mp make_pair

#define lowbit(x) (x & (-x))

#define PII  pair<int, int> 

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

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

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

#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)

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

template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }

template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }

typedef long long ll;

typedef unsigned long long ull;

const db eps = 1e-9;

const db PI = acos(-1);

const int inf = 0x3f3f3f3f;

const int mod = (int)1e9 + 7;

const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE

const ll INF = 0x3f3f3f3f3f3f3f3f;

using namespace std;

ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }



inline int read(){

	char ch = getchar();

	int x = 0, f = 1;

	while(ch < '0' || ch > '9'){

		if(ch == '-') f = -1;

		ch = getchar();

	}

	while('0' <= ch && ch <= '9'){

		x = x * 10 + ch - '0';

		ch = getchar();

	}

	return x * f;

}



int n;

int h[maxn], dp[maxn];



int main()

{

	n = read();

	rep(i, 1, n) h[i] = read();

	memset(dp, 0x3f, sizeof dp);

	dp[1] = 0;

	rep(i, 1, n){

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

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

	}

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

	return 0;

}

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

    #define maxn 100000

    #define INF 1LL<<60

    using namespace std;

    long long h[maxn+3], dp[maxn+3];

    int n;



    long long solve(int cur){

        if(cur >= n) return INF;

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

        if(dp[cur]!= INF) return dp[cur];

        //long long res1 = INF, res2 = INF;

        long long res1 = solve(cur+1) + llabs(h[cur+1]-h[cur]);

        long long res2 = solve(cur+2) + llabs(h[cur+2]-h[cur]);

        return dp[cur] = min(res1, res2); 

    }



    int main() {

    	// your code goes here

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

    	while(scanf("%d",&n)==1){

            

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

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

                dp[i] = INF;

            }



            long long ans = solve(0);

            printf("%lld\n", ans);

        }

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

    #define maxn 100000

    #define INF 1LL<<60

    using namespace std;

    long long h[maxn+3], dp[maxn+3];

    int n;



    long long solve(int cur){

        if(cur >= n) return INF;

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

        if(dp[cur]!= INF) return dp[cur];

        //long long res1 = INF, res2 = INF;

        long long res1 = solve(cur+1) + llabs(h[cur+1]-h[cur]);

        long long res2 = solve(cur+2) + llabs(h[cur+2]-h[cur]);

        return dp[cur] = min(res1, res2); 

    }



    int main() {

    	// your code goes here

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

    	while(scanf("%d",&n)==1){

            

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

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

                dp[i] = INF;

            }



            long long ans = solve(0);

            printf("%lld\n", ans);

        }

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

    #define maxn 100000

    #define INF 1LL<<60

    using namespace std;

    long long h[maxn+3], dp[maxn+3];

    int n;



    long long solve(int cur){

        if(cur >= n) return INF;

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

        if(dp[cur]!= INF) return dp[cur];

        //long long res1 = INF, res2 = INF;

        long long res1 = solve(cur+1) + llabs(h[cur+1]-h[cur]);

        long long res2 = solve(cur+2) + llabs(h[cur+2]-h[cur]);

        return dp[cur] = min(res1, res2); 

    }



    int main() {

    	// your code goes here

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

    	while(scanf("%d",&n)==1){

            

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

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

                dp[i] = INF;

            }



            long long ans = solve(0);

            printf("%lld\n", ans);

        }

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

    #define maxn 100000

    #define INF 1LL<<60

    using namespace std;

    long long h[maxn+3], dp[maxn+3];

    int n;



    long long solve(int cur){

        if(cur >= n) return INF;

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

        if(dp[cur]!= INF) return dp[cur];

        //long long res1 = INF, res2 = INF;

        long long res1 = solve(cur+1) + llabs(h[cur+1]-h[cur]);

        long long res2 = solve(cur+2) + llabs(h[cur+2]-h[cur]);

        return dp[cur] = min(res1, res2); 

    }



    int main() {

    	// your code goes here

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

    	while(scanf("%d",&n)==1){

            

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

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

                dp[i] = INF;

            }



            long long ans = solve(0);

            printf("%lld\n", ans);

        }

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

    #define maxn 100000

    #define INF 1LL<<60

    using namespace std;

    long long h[maxn+3], dp[maxn+3];

    int n;



    long long solve(int cur){

        if(cur >= n) return INF;

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

        if(dp[cur]!= INF) return dp[cur];

        //long long res1 = INF, res2 = INF;

        long long res1 = solve(cur+1) + llabs(h[cur+1]-h[cur]);

        long long res2 = solve(cur+2) + llabs(h[cur+2]-h[cur]);

        return dp[cur] = min(res1, res2); 

    }



    int main() {

    	// your code goes here

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

    	while(scanf("%d",&n)==1){

            

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

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

                dp[i] = INF;

            }



            long long ans = solve(0);

            printf("%lld\n", ans);

        }

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

    #define maxn 100000

    #define INF 1LL<<60

    using namespace std;

    long long h[maxn+3], dp[maxn+3];

    int n;



    long long solve(int cur){

        if(cur >= n) return INF;

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

        if(dp[cur]!= INF) return dp[cur];

        //long long res1 = INF, res2 = INF;

        long long res1 = solve(cur+1) + llabs(h[cur+1]-h[cur]);

        long long res2 = solve(cur+2) + llabs(h[cur+2]-h[cur]);

        return dp[cur] = min(res1, res2); 

    }



    int main() {

    	// your code goes here

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

    	while(scanf("%d",&n)==1){

            

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

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

                dp[i] = INF;

            }



            long long ans = solve(0);

            printf("%lld\n", ans);

        }

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

     

    using namespace std;

     

    void __print(int x) {

        cerr << x;

    }

    void __print(long x) {

       cerr << x;

    }

    void __print(long long x) {

       cerr << x;

    }

    void __print(unsigned x) {

        cerr << x;

    }

    void __print(unsigned long x) {

        cerr << x;

    }

    void __print(unsigned long long x) {

        cerr << x;

    }

    void __print(float x) {

        cerr << x;

    }

    void __print(double x) {

        cerr << x;

    }

    void __print(long double x) {

        cerr << x;

    }

    void __print(char x) {

        cerr << '\'' << x << '\'';

    }

    void __print(const char *x) {

        cerr << '\"' << x << '\"';

    }

    void __print(const string &x) {

        cerr << '\"' << x << '\"';

    }

    void __print(bool x) {

        cerr << (x ? "true" : "false");

    }

     

    template<typename T, typename V>

    void __print(const pair<T, V> &x) {

        cerr << '{'; 

        __print(x.first); cerr << ','; 

       __print(x.second); cerr << '}';

    }

    template<typename T>

    void __print(const T &x) {

        int f = 0; cerr << '{'; 

        for (auto &i: x) 

            cerr << (f++ ? "," : ""), __print(i); 

        cerr << "}";

    }

    void _print() {

        cerr << "]\n";

    }

    template <typename T, typename... V>

    void _print(T t, V... v) {

        __print(t); 

        if (sizeof...(v)) 

            cerr << ", "; _print(v...);

    }

     

    #ifndef ONLINE_JUDGE

    #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

    #else

    #define debug(x...)

    #endif

     

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

    #define forw(i, w) for(int i = n; i >= 0; i--)

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

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

    #define read(v) for(auto &i:v) cin >> i;

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

     

    typedef long long ll;

    typedef vector<int> vi;

    typedef vector<double> vd;

    typedef pair<int, int> pii;

     

    int n, k;

    vi arr, dp;

     

    int main(){

    	ios_base::sync_with_stdio(0);

    	cout.tie(0);cin.tie(0);

    	

    	cin >> n;

    	k=2;

    	arr.assign(n, 0);

    	dp.assign(n, 999999999);

    	dp[0] = 0;

    	read(arr);

     

    	forn(i, n)

    		for(int j = i+1; j < n && j < i+k+1; j++)

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

     

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

    	return 0;

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

     

    using namespace std;

     

    void __print(int x) {

        cerr << x;

    }

    void __print(long x) {

       cerr << x;

    }

    void __print(long long x) {

       cerr << x;

    }

    void __print(unsigned x) {

        cerr << x;

    }

    void __print(unsigned long x) {

        cerr << x;

    }

    void __print(unsigned long long x) {

        cerr << x;

    }

    void __print(float x) {

        cerr << x;

    }

    void __print(double x) {

        cerr << x;

    }

    void __print(long double x) {

        cerr << x;

    }

    void __print(char x) {

        cerr << '\'' << x << '\'';

    }

    void __print(const char *x) {

        cerr << '\"' << x << '\"';

    }

    void __print(const string &x) {

        cerr << '\"' << x << '\"';

    }

    void __print(bool x) {

        cerr << (x ? "true" : "false");

    }

     

    template<typename T, typename V>

    void __print(const pair<T, V> &x) {

        cerr << '{'; 

        __print(x.first); cerr << ','; 

       __print(x.second); cerr << '}';

    }

    template<typename T>

    void __print(const T &x) {

        int f = 0; cerr << '{'; 

        for (auto &i: x) 

            cerr << (f++ ? "," : ""), __print(i); 

        cerr << "}";

    }

    void _print() {

        cerr << "]\n";

    }

    template <typename T, typename... V>

    void _print(T t, V... v) {

        __print(t); 

        if (sizeof...(v)) 

            cerr << ", "; _print(v...);

    }

     

    #ifndef ONLINE_JUDGE

    #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

    #else

    #define debug(x...)

    #endif

     

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

    #define forw(i, w) for(int i = n; i >= 0; i--)

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

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

    #define read(v) for(auto &i:v) cin >> i;

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

     

    typedef long long ll;

    typedef vector<int> vi;

    typedef vector<double> vd;

    typedef pair<int, int> pii;

     

    int n, k;

    vi arr, dp;

     

    int main(){

    	ios_base::sync_with_stdio(0);

    	cout.tie(0);cin.tie(0);

    	

    	cin >> n;

    	k=2;

    	arr.assign(n, 0);

    	dp.assign(n, 999999999);

    	dp[0] = 0;

    	read(arr);

     

    	forn(i, n)

    		for(int j = i+1; j < n && j < i+k+1; j++)

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

     

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

    	return 0;

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

using namespace std;

#define N (int)2e5

int n,memo[N],c[N];



int dp(int curr) {

    if (curr == n) return 0;

    if (curr > n) return 1e9;

    int &sol = memo[curr];

    if (sol != -1) return sol;

    sol = min(

        dp(curr + 1) + abs(c[curr] - c[curr + 1]) ,

        dp(curr + 2) + abs(c[curr] - c[curr + 2])

    );

    return sol;

}



int main() {

    scanf("%d" , &n);

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

        scanf("%d" , &c[i]);

    memset (memo , -1 , sizeof memo);

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

}


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

}