stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<cstdio>

#include<iostream>

#include<cmath>

#include<stack>

#include<cstring>

#include<algorithm>

using namespace std;

int n;

int h[100005];

int dp[100005];



int main()

{

memset(dp, 0x3f ,sizeof dp);

scanf("%d",&n);

for( int i = 1 ; i <= n ; i++) scanf("%d",&h[i]);

dp[1] = 0;

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

{

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

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

}

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



	return 0;

}






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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

using namespace std;

#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'

const int N = 1e5;

const int inf = 1e9;

int A[N+7], dp[N+7];

int n;



int solve(int i) {

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

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

	int res1 = solve(i+1) + abs(A[i]-A[i+1]);

	int res2 = inf;

	if(i+2<=n-1) res2 = solve(i+2)+abs(A[i]-A[i+2]);

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

}

int main(){

	ios_base::sync_with_stdio(0);

	int a,b,T,cas=0;

	cin>>n;

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

	fill(dp,dp+n,-1);

	int res=solve(0);

	cout<<res<<endl;

	return 0;

}

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

#define ll long long

#define ull unsigned ll

#define ld long double

#define pll pair<ll, ll>

#define pii pair<int, int>

#define f first

#define se second

#define pb push_back

#define ft fflush(stdout)

 

 

using namespace std;

 

 

const int N = 2e5 + 123;

const int PLS = 3e5 + 123;

const int mod = 1e9 + 7;

const ll inf = 1e16;





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





int main() {

    ios_base::sync_with_stdio(NULL);

    cin.tie(NULL); cout.tie(NULL);

    cin >> n;

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

        cin >> a[i];

    dp[1] = 0;

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

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

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

    cout << dp[n];

}

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

#include<cstdio>

#include<string>

#include<cstring>

#include<algorithm>

#include<queue>

#include<stack>

#include<map>

#include<vector>

#include<set>

#include<list>

#define ll long long

using namespace std;

ll h[200050],dp[200050];

int main()

{

	ll n;

	cin>>n;

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

		cin>>h[i];

	memset(dp,0,sizeof(dp));

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

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

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

	cout<<dp[n]<<endl;

	return 0;

}

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

}
// Slower C++ solution:
//#pragma GCC target("avx2")

//#pragma GCC optimize("O3")

   

//#include <x86intrin.h>

#include <bits/stdc++.h>   

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

 

using namespace __gnu_pbds;

using namespace std;



template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

     

#define F first

#define S second           

#define lb lower_bound               

#define ub upper_bound

#define pb push_back

#define pf push_front    

#define ppb pop_back

#define mp make_pair                                     

#define bpp __builtin_popcountll                                                                                        

#define sqr(x) ((x) * (x)) 

#define al 0x3F3F3F3F

#define sz(x) (int)x.size()

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

#define in insert

#define ppf pop_front

#define endl '\n'

//#define int long long

 

typedef unsigned long long ull;

typedef long long ll;

typedef long double ld;

typedef pair <int, int> pii;

 

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

const int N = (int)3e5 + 123;

const ll inf = (ll)1e18 + 1;



const double pi = acos (-1.0);

const double eps = 1e-7;                  

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

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



int n;

ll h[N];

ll dp[N];



inline void boost () {                    

   ios_base :: sync_with_stdio (NULL);

   cin.tie (NULL), cout.tie (NULL);          

}                                                     



inline void Solve () {

   cin >> n;

   dp[1] = 0;

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

   for (int i = 2; i <= n; i ++) dp[i] = inf;

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

      if (i + 1 <= n) dp[i + 1] = min (dp[i + 1], dp[i] + abs (h[i] - h[i + 1]));

      if (i + 2 <= n) dp[i + 2] = min (dp[i + 2], dp[i] + abs (h[i] - h[i + 2]));

   }

   cout << dp[n];

}



main () {                                       

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

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

   boost ();

   int tt = 1;

   //cin >> tt;   

   while (tt --) {

      Solve ();

   }                                               

   return 0;      

}

                          

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

}
// Slower C++ solution:
    #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);

        }

    }

     

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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



using namespace std;

const int maxn = 2e5+2;

const int mod = 1e9+7;

const int inf = 1e9;



typedef long long ll;



int n;

int arr[maxn], dp[maxn];



int solve_dp (int pos){

    if (pos > n) return inf;

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



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



    int ans = inf;

    ans = min(ans, solve_dp(pos + 1) + abs(arr[pos + 1] - arr[pos]));

    ans = min(ans, solve_dp(pos + 2) + abs(arr[pos + 2] - arr[pos]));



    return dp[pos] = ans;

}



int main(){



    ios_base::sync_with_stdio(0);

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



    cin >> n;



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

        cin >> arr[i];

    }



    memset(dp, -1, sizeof dp);



    cout << solve_dp(0) << "\n";



    return 0;

}


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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

#include<cmath>

#include<cstdio>

#include<cstring>

using namespace std;

int n,m,f[1100000],w[1100000];

int main ()

{

	cin>>n;

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

	{

		cin>>w[i];

	}

	f[2]=abs(w[2]-w[1]);

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

	{

		f[i]=min(f[i-1]+abs(w[i]-w[i-1]),f[i-2]+abs(w[i]-w[i-2]));

	}	

	cout<<f[n];

}

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

#include <algorithm>

#include <cmath>

#include <cstdlib>

#include <cstdio>

#include <cstring>

#include <iomanip>

#include <string>

#include <set>

#include <vector>

#include <queue>

#include <stack>

#include <map>

using namespace std;

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

#define fore(i, a, n) for (long long i = a; i < n; i++)

#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)

#define si(a) scanf("%d", &a)

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

#define sii(a, b) scanf("%d%d", &a, &b)

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

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

#define debug(a) cout << a << endl

#define pr(a) printf("%d ",a)

#define endl '\n'

#define pi acos(-1.0)

#define tr t[root]

#define lson t[root << 1]

#define rson t[root << 1 | 1]

#define IO ios::sync_with_stdio(false), cin.tie(0)

#define ull unsigned long long

const double eps = 1e-8;

inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }

typedef long long ll;

const int inf=0x3f3f3f3f;

const int MAXN = 1e5 + 10;

int n,a[MAXN];

ll dp[MAXN];

int main()

{

	si(n);

	for(int i=1;i<=n;++i)si(a[i]);

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

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

	{

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

	}

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

 } 

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

}
// Slower C++ solution:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

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

typedef long long ll;

using namespace std;

ll n , arr[100005] , memo[100005];

ll solve(ll i)

{

	if(i == n - 1)

		return 0;

	ll &ans = memo[i];

	if(~ans)

		return ans;

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

	if(i < n - 2)

		ans = min(ans , abs(arr[i] - arr[i + 2]) + solve(i + 2));

	return ans;

}

int main()

{

	abdelrahman010

	cin >> n;

	memset(memo , -1 , sizeof memo);

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

		cin >> arr[i];

	cout << solve(0);

	return 0;

}


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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

using namespace std;

#define ll long long

#define pb push_back

#define F first

#define S second

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

ll n, k, h[A], dp[A];

ll table1()

{

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

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

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

	return dp[n-1];

}

ll table2()

{

	dp[0] = 0;

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

	{

		dp[i] = 1e9;

		for (int j = max(0, i - (int)k); j < i; j++)

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

	}

	return dp[n-1];

}

int main()

{

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

	cin >> n;

	//cin >> k;

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

	cout << table1();

	//cout << table2();

	return 0;

}


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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

}
// 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: 2.298792122488194x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

#include<vector>

using namespace std;

 

int dp[100010];

int n;

int conti;

bool pasa;

int main(){

     cin >> n;

    vector<int> h(n);

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

        conti ++;

        cin >> h[i];

        if(conti > 0){

        conti--;

        pasa = true;

       //printf("prueba")

}

    }

    dp[0] = 0;

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

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

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

    }

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

}

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

#include <vector>

#include <cmath>

#include <map>

#include<algorithm>

#include<string.h>

using namespace std;

int main() {

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

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

   	int n;

   	cin>>n;

   	int a[100000];

   	int b[100000];

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

   		cin>>a[i];

   	b[0]=0;

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

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

   	{

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

	}

	cout<<b[n-1];

}

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

#include<cstdio>

#include<cmath>

#include<cstring>

#define Max(a,b) (a>b?a:b)

#define Min(a,b) (a<b?a:b)

using namespace std;

const int MAXN = 1e5+10, INF = 0x3f3f3f3f;

int A[MAXN], dp[MAXN], N;



int main()

{

	scanf("%d", &N);

	int i;

	for(i=1;i<=N;i++) scanf("%d", &A[i]), dp[i] = INF;

	dp[1] = 0;

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

	for(i=3;i<=N;i++) {

		dp[i] = Min(dp[i], Min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2])));

	}

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

	return 0;

}

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

#include <vector>

#include <algorithm>

#include <stdio.h>

#include <map>

using namespace std;

#define min(a,b) (a>b?b:a);

int main(){

	int n;

	cin>>n;

	vector<int> path(n);

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

	vector<int> dp(n);

	dp[0]=0;

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

	if(n==2){

		cout<<dp[1]<<endl;

		return 0;

	}

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

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

	}

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

	return 0;

}

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

#include<stdio.h>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

#define maxn 100005

int dp[maxn];

int h[maxn];

int n;

int main(){

    scanf("%d",&n);

    memset(dp,0,sizeof(dp));

    memset(h,0,sizeof(h));

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

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

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

        if(i-1>=1&&i-2>=1)

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

        else if(i-1>=1) dp[i] = dp[i-1]+abs(h[i]-h[i-1]);

        else if(i-2>=1) dp[i] = dp[i-2]+abs(h[i]-h[i-2]);

    }

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

    return 0;

}


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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

#include<algorithm>

#define MAXN 100010 

using namespace std;

int h[MAXN];

int dp[MAXN];

int main() {

	int N;

	cin >> N;

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

		cin >> h[i];

	}

	dp[0] = 0;

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

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

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

		

	}

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

	//system("pause");

	return 0;

}

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

#include<algorithm>

using namespace std;

int main(){

    int dp[100001]={0};

    int stone[100001];

    int n;

    scanf("%d",&n);

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

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

    }

    dp[1] = 0;

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

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

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

    }

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

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

using namespace std;

#define INF 100005

#define maxx 1000000000000



int n;

long long a[INF+5];

long long mem[INF];



long long rec(int pos)

{

    if(pos==n-1)

    {

        return 0;

    }

    if(mem[pos]!=-1) return mem[pos];

    long long tot=maxx;

    long long left=abs(a[pos]-a[pos+1]);

    long long right=abs(a[pos]-a[pos+2]);

    if(pos+1<n)

    {

        tot=min(tot,left+rec(pos+1));

    }

    if(pos+2<n)

    {

        tot=min(tot,right+rec(pos+2));

    }

    return mem[pos]=tot;

}



int main()

{

    memset(a,0,sizeof(a));

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

    scanf("%d",&n);

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

    {

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

    }

    long long ans=rec(0);

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

}


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

{

    ios_base::sync_with_stdio(false);

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

    cin>>c;



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

    {

        cin>>v[i];

    }



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



    return 0;

}