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



using namespace std;



typedef long long ll;

const double eps=1e-6,pi=acos(-1);

const int N=1e5+5,M=1e9+7,SEGM=4*N,OO=0x3f3f3f3f;

int n,m,a[N],b[N],c[N];

int mem[N];



int solve(int i=0){

    if(i>=n) return 1e9;

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

    int &ret=mem[i];

    if(~ret) return ret;

    ret=1e9;

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

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

    return ret;

}



int main(){

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

    scanf("%d",&n);

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

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

    memset(mem,-1,sizeof mem);

    printf("%d",solve());

    return 0;

}


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

using namespace std;

 

#define MOD (1000000007)

#define f first

#define s second

#define pb(x) push_back(x)

#define mp(x,y) make_pair(x,y)

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

#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

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

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

#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

typedef long long int ll;

#define ld long double

const int N = 2e5+30;

//https://codeforces.com/problemset/page/2?tags=1700-1700

 

 

void solve(){

   int n;

   cin>>n;

   int a[n+3];

   int dp[n+3];

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

     dp[i] = 1e9;

   }

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

     cin>>a[i];

   }

   dp[1]  = 0;

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

     if(i-1>=1){

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

     }

     if(i-2>=1){

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

     }

   }

   cout<<dp[n]<<'\n';

}

 

 

int main(){

 	ios_base::sync_with_stdio(false);

  cin.tie(NULL);

	int T;

  //cin >> T;

  //cout<<prs.size()<<'\n';

	 T = 1;

  //visited[1]=1;

	while(T--){

		solve();

	}

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

 

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//#pragma GCC optimize("Ofast")

//1.0 * clock() / CLOCKS_PER_SEC

 

#define fi first

#define se second

#define ll long long int

#define dl double long

 

using namespace std;

 

const int N = 1e5 + 7;

const ll mod = 1e9 + 7;



vector<int> dp(N);



void solve1()

{

	int n;

	cin >> n;

	int ar[n];

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

		cin >> ar[i];

	dp[1] = 0;

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

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

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

	}

	cout << dp[n];

}

int main()

{

    ios_base::sync_with_stdio(0);

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

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

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

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

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

    

    int cghf = 1;//cin >> cghf;

    while( cghf-- ){

        solve1();

    }

}


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

using namespace std;

 

#define MOD (1000000007)

#define f first

#define s second

#define pb(x) push_back(x)

#define mp(x,y) make_pair(x,y)

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

#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

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

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

#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

typedef long long int ll;

#define ld long double

const int N = 2e5+30;

//https://codeforces.com/problemset/page/2?tags=1700-1700

 

 

void solve(){

   int n;

   cin>>n;

   int a[n+3];

   int dp[n+3];

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

     dp[i] = 1e9;

   }

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

     cin>>a[i];

   }

   dp[1]  = 0;

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

     if(i-1>=1){

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

     }

     if(i-2>=1){

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

     }

   }

   cout<<dp[n]<<'\n';

}

 

 

int main(){

 	ios_base::sync_with_stdio(false);

  cin.tie(NULL);

	int T;

  //cin >> T;

  //cout<<prs.size()<<'\n';

	 T = 1;

  //visited[1]=1;

	while(T--){

		solve();

	}

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



typedef   long long  int ll;

typedef  long double ld;

typedef std::vector<ll> vi;

typedef std::vector<std::vector<ll> > vv;



#define MOD 1000000007

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

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

#define mp make_pair

#define pb(x) push_back(x)

#define fi first

#define se second

#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;

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

#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];

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

using namespace std;



const int N = 1e5 + 5;





void solve(){

            ll i,j,n,m;

            ll mincost[N];

            ms(mincost,0);

            cin>>n;

            ll a[n];

            input(a,0,n);

            mincost[1] = abs(a[0]-a[1]);//a[0];

            fo(i,2,n)

            {

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

			}

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

            

    

            

						            



















}



int main()

{

    IO;

      ll t=1;

      //cin>>t;





      while(t--)

      {



          solve();

      }

    return 0;

}


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

using namespace std;

 

#define MOD (1000000007)

#define f first

#define s second

#define pb(x) push_back(x)

#define mp(x,y) make_pair(x,y)

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

#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

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

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

#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

typedef long long int ll;

#define ld long double

const int N = 2e5+30;

//https://codeforces.com/problemset/page/2?tags=1700-1700

 

 

void solve(){

   int n;

   cin>>n;

   int a[n+3];

   int dp[n+3];

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

     dp[i] = 1e9;

   }

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

     cin>>a[i];

   }

   dp[1]  = 0;

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

     if(i-1>=1){

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

     }

     if(i-2>=1){

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

     }

   }

   cout<<dp[n]<<'\n';

}

 

 

int main(){

 	ios_base::sync_with_stdio(false);

  cin.tie(NULL);

	int T;

  //cin >> T;

  //cout<<prs.size()<<'\n';

	 T = 1;

  //visited[1]=1;

	while(T--){

		solve();

	}

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

using namespace std;

int n , a[1000000] , frog , memo[1000000];



int f(int n){

	if(n == 1)return 0;

	if(n == 2)return abs(a[1] - a[2]);

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

	memo[n] = min(f(n-1) + abs(a[n] - a[n-1]) , f(n-2) + abs(a[n] - a[n-2]));

	return memo[n];

}

int main(){

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

	scanf("%d" , &n);

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

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

	}

	printf("%d" , f(n));

}

// Faster C++ solution for the same problem (measured speedup: 2.808800437471023x):
/* In the name of Allah */



#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define pii pair<int, int>

#define pll pair<long long, long long>

#define pb push_back

#define LL_INF 1LL << 62

#define INF 1 << 30

#define SetBit(x, k) (x |= (1LL << k))

#define ClearBit(x, k) (x &= ~(1LL << k))

#define CheckBit(x, k) (x & (1LL << k))

#define mod 1000000007



int n;

ll x[100005];

ll dp[100005];



ll solve(int pos){

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

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



  ll res = LL_INF;

  if(pos+1<n) res = min(res, abs(x[pos+1]-x[pos])+solve(pos+1));

  if(pos+2<n) res = min(res, abs(x[pos+2]-x[pos])+solve(pos+2));



  return dp[pos] = res;

}



int main()

{

  memset(dp, -1, sizeof dp);

  cin >> n;

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

    cin >> x[i];



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



  return 0;

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



using namespace std;

int v[1000010];

int memo[1000010];

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: 2.8179647357187267x):
/* In the name of Allah */



#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define pii pair<int, int>

#define pll pair<long long, long long>

#define pb push_back

#define LL_INF 1LL << 62

#define INF 1 << 30

#define SetBit(x, k) (x |= (1LL << k))

#define ClearBit(x, k) (x &= ~(1LL << k))

#define CheckBit(x, k) (x & (1LL << k))

#define mod 1000000007



int n;

ll x[100005];

ll dp[100005];



ll solve(int pos){

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

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



  ll res = LL_INF;

  if(pos+1<n) res = min(res, abs(x[pos+1]-x[pos])+solve(pos+1));

  if(pos+2<n) res = min(res, abs(x[pos+2]-x[pos])+solve(pos+2));



  return dp[pos] = res;

}



int main()

{

  memset(dp, -1, sizeof dp);

  cin >> n;

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

    cin >> x[i];



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



  return 0;

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



using namespace std;



#define F first

#define S second



int N;

int H[100005];

int dp[100005][5];



int solve(int cost, int ind, int j) {

	if (ind > N) return INT32_MAX;

	if (ind == N) return cost;



	if (~dp[ind][j]) return dp[ind][j];

	

	dp[ind][j] = cost;

	dp[ind][j] += min(solve(abs(H[ind] - H[ind + 1]), ind + 1, 0), 

					solve(abs(H[ind] - H[ind + 2]), ind + 2, 1));

	return dp[ind][j];

}



int main() {

	cin >> N; 

	H[0] = INT32_MAX; // to avoid RTE

	for (int i = 1; i <= N; i++) cin >> H[i];

	int ans = 0;

	

	memset(dp, -1, sizeof dp);

	cout << solve(0, 1, 0) << endl;



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.6645244627301632x):
/* In the name of Allah */



#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define pii pair<int, int>

#define pll pair<long long, long long>

#define pb push_back

#define LL_INF 1LL << 62

#define INF 1 << 30

#define SetBit(x, k) (x |= (1LL << k))

#define ClearBit(x, k) (x &= ~(1LL << k))

#define CheckBit(x, k) (x & (1LL << k))

#define mod 1000000007



int n;

ll x[100005];

ll dp[100005];



ll solve(int pos){

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

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



  ll res = LL_INF;

  if(pos+1<n) res = min(res, abs(x[pos+1]-x[pos])+solve(pos+1));

  if(pos+2<n) res = min(res, abs(x[pos+2]-x[pos])+solve(pos+2));



  return dp[pos] = res;

}



int main()

{

  memset(dp, -1, sizeof dp);

  cin >> n;

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

    cin >> x[i];



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



  return 0;

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

using namespace std;

//-------------------------------------------MACROS---------------------------------------------

#define 	TIEMPO_CORRIDA		cerr << "tiempo: "<<1.0*clock()/CLOCKS_PER_SEC <<" seg.\n";

#define 	FILES				freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);

#define 	FORIT(it,e)			for(it = e.begin() ; it != e.end() ; it++)

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

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

#define 	FORSW(i,a,b,sw)		for(i = a ; i < b && sw ; i++)

#define 	RFORSW(i,a,b,sw)	for(i = a ; i >= b && sw ; i--)

#define 	fast 				ios::sync_with_stdio(false),cin.tie(),cout.tie();

#define 	to_int(x) 			atoi(x.data())

#define 	to_long(x) 			atoll(x.data())

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

#define 	RALL(x) 			x.rbegin(),x.rend()

typedef 	long long 			ll;

typedef 	pair<int,int> 		pi;

typedef 	pair<ll,ll> 		pl;

const		int 				modN = 1e9+7;

const		double 				PI = 3.1415926535897932384626433832795028841;

//---------------------------------------------------------------------------------------------

const int tam = 6e5;

const int oo=1e9;

int ar[tam],memo[tam];

int n;



int f(int x){

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

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

	int a=oo , b=oo;

	if(x+1 <n) a = f(x+1) + abs(ar[x+1]-ar[x]); 

	if(x+2 <n) b = f(x+2) + abs(ar[x+2]-ar[x]);

	return memo[x]=min(a,b);

}



int main(){

	int i;

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

		memset(memo,-1,sizeof memo);

		FOR(i,0,n) scanf("%d",&ar[i]);

		printf("%d\n",f(0));

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8770853075694665x):
/* In the name of Allah */



#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define pii pair<int, int>

#define pll pair<long long, long long>

#define pb push_back

#define LL_INF 1LL << 62

#define INF 1 << 30

#define SetBit(x, k) (x |= (1LL << k))

#define ClearBit(x, k) (x &= ~(1LL << k))

#define CheckBit(x, k) (x & (1LL << k))

#define mod 1000000007



int n;

ll x[100005];

ll dp[100005];



ll solve(int pos){

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

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



  ll res = LL_INF;

  if(pos+1<n) res = min(res, abs(x[pos+1]-x[pos])+solve(pos+1));

  if(pos+2<n) res = min(res, abs(x[pos+2]-x[pos])+solve(pos+2));



  return dp[pos] = res;

}



int main()

{

  memset(dp, -1, sizeof dp);

  cin >> n;

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

    cin >> x[i];



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



  return 0;

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

#define ll long long

#define endl "\n"

using namespace std;

inline int D()

{

    int t;

    scanf("%d",&t);

    return t;

}

inline ll llD()

{

    ll t;

    scanf("%lld",&t);

    return t;

}



const int Max=1e6+9;

const int OO=-1e6;

int st[4]= {1,0,0,-1};

int nt[4]= {0,1,-1,0};

int n,m;

bool valid(int x,int y)

{

    return x>-1 && y>-1 && x<n && y<m;

}

ll mem[Max];

void init()

{

    memset(mem,-1,sizeof mem);

}

//////////////////////////////////////////////////////////



ll a[Max];



ll solve (int i )

{

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

    if(i>=n)

        return Max;



    ll &ret=mem[i];

    if(~ret)return ret;



    ll take1 =solve(i+1)+abs(a[i]-a[i+1]);

    ll take2 =solve(i+2)+abs(a[i]-a[i+2]);



     return mem[i]=min(take2,take1);

}



void Fast()

{

    std::ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    cerr.tie(0);

}

int main()

{

   init();

   n =D();

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

   {

       a[i]=llD();

   }

   printf("%lld",solve(0));



}


// Faster C++ solution for the same problem (measured speedup: 5.19263933054465x):
/* In the name of Allah */



#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define pii pair<int, int>

#define pll pair<long long, long long>

#define pb push_back

#define LL_INF 1LL << 62

#define INF 1 << 30

#define SetBit(x, k) (x |= (1LL << k))

#define ClearBit(x, k) (x &= ~(1LL << k))

#define CheckBit(x, k) (x & (1LL << k))

#define mod 1000000007



int n;

ll x[100005];

ll dp[100005];



ll solve(int pos){

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

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



  ll res = LL_INF;

  if(pos+1<n) res = min(res, abs(x[pos+1]-x[pos])+solve(pos+1));

  if(pos+2<n) res = min(res, abs(x[pos+2]-x[pos])+solve(pos+2));



  return dp[pos] = res;

}



int main()

{

  memset(dp, -1, sizeof dp);

  cin >> n;

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

    cin >> x[i];



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



  return 0;

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

using namespace std;

const int mx = 100005;

int dp[mx];

int A[mx];

void memo(int i,int n)

{

	if(i>n) return;

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

	memo(i+1,n);

}

int main()

{

     int n;cin>>n;

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

     	cin>>A[i];

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

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

     memo(3,n);

     cout<<dp[n]<<endl;

     return 0;

}

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

#define ll long long

using namespace std;



int dp[100005], a[100005];

int n;



int main()

{

    cin>>n;

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

        cin>>a[i];



    dp[1]=0;

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

    {

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

        if(i>2)

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

    }

    cout<< dp[n] <<endl;

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

using namespace std;



#define INF 1e18;

#define MAX_N 100005

long long N, h[MAX_N], memo[MAX_N];



long long dp(int pos) {

  if (pos < 1) {

  	return INF;

  }

  if (pos == 1) {

  	return 0;

  }

  if (pos == 2) {

  	return abs(h[2] - h[1]);

  }

  if (memo[pos] != -1) {

  	return memo[pos];

  }

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

}



int main() {

  cin >> N;

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

  	cin >> h[i];

  }

  /*

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

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

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

  }

  */

  /*

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

  	cout << i << ' ' << memo[i] << '\n';

  }

  */

  // cout << memo[N] << '\n';

  memset(memo, -1, sizeof memo);

  cout << dp(N) << '\n';

}

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

#define ll long long

using namespace std;



int dp[100005], a[100005];

int n;



int main()

{

    cin>>n;

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

        cin>>a[i];



    dp[1]=0;

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

    {

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

        if(i>2)

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

    }

    cout<< dp[n] <<endl;

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

using namespace std;

int n , a[1000000] , frog , memo[1000000];



int f(int n){

	if(n == 1)return 0;

	if(n == 2)return abs(a[1] - a[2]);

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

	memo[n] = min(f(n-1) + abs(a[n] - a[n-1]) , f(n-2) + abs(a[n] - a[n-2]));

	return memo[n];

}

int main(){

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

	scanf("%d" , &n);

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

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

	}

	printf("%d" , f(n));

}

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

#define ll long long

using namespace std;



int dp[100005], a[100005];

int n;



int main()

{

    cin>>n;

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

        cin>>a[i];



    dp[1]=0;

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

    {

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

        if(i>2)

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

    }

    cout<< dp[n] <<endl;

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

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f3f3f3f

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

#define pb push_back

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

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

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

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

using namespace std;

const int mod = 1e9;

const int N = 1e5+10;

/*=======================================================================*/



int n, h[N], sum;

int f[N];



int main() {

   scanf("%d", &n);

   for1(i, n) {

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

   }

   ms(f, inf);

   f[n] = 0;

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

      if(i == 2) {

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

      } else {

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

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

      }

      // if(i == 2) {

      //    sum += abs(h[i] - h[1]);

      //    i--;

      // } else {

      //    if(abs(h[i] - h[i-1]) < abs(h[i] - h[i-2])) {

      //       sum += abs(h[i] - h[i-1]);

      //       i -= 1;

      //    } else {

      //       sum += abs(h[i] - h[i-2]);

      //       i -= 2;

      //    }

      // }

   }

   cout << f[1] << endl;

   return 0;

}

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

#define ll long long

using namespace std;



int dp[100005], a[100005];

int n;



int main()

{

    cin>>n;

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

        cin>>a[i];



    dp[1]=0;

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

    {

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

        if(i>2)

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

    }

    cout<< dp[n] <<endl;

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

using namespace std;



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

#define ll long long

using namespace std;



int dp[100005], a[100005];

int n;



int main()

{

    cin>>n;

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

        cin>>a[i];



    dp[1]=0;

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

    {

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

        if(i>2)

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

    }

    cout<< dp[n] <<endl;

}
// 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 ppt = 1e5+3;

int n;

int dp[ppt];

int a[ppt];

int f(int i){

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

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

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

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

	return dp[i]=jpr;

}

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

#define ll long long

using namespace std;



int dp[100005], a[100005];

int n;



int main()

{

    cin>>n;

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

        cin>>a[i];



    dp[1]=0;

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

    {

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

        if(i>2)

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

    }

    cout<< dp[n] <<endl;

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

#define ll long long

using namespace std;



int dp[100005], a[100005];

int n;



int main()

{

    cin>>n;

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

        cin>>a[i];



    dp[1]=0;

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

    {

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

        if(i>2)

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

    }

    cout<< dp[n] <<endl;

}