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

using namespace std;



typedef long long int ll;

typedef long double ld;



#define Pb push_back

#define Mp make_pair



#define ff first

#define ss second



#define Max(x,y,z) max(x,max(y,z))

#define Min(x,y,z) min(x,min(y,z))



#define INF LONG_LONG_MAX

#define MINF LONG_LONG_MIN



#define endl "\n"

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



#define db1(x) cout<<#x<<" : "<<x<<endl;

#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;

#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;



const int N = 1e5+5;

int h[N];

int n;

int dp[N];



int solution(int idx)

{

  if(idx == n)

  {

    return 0;

  }

  if(idx>n)

  {

    return 10000000;

  }

  if(dp[idx] != -1)

  {

    return dp[idx];

  }

  int &ans = dp[idx];

  int dp1=INT_MAX;

  int dp2=INT_MAX;

  if(idx+1 <= n) dp1 = solution(idx+1)+abs(h[idx]-h[idx+1]);

  if(idx+2 <= n) dp2 = solution(idx+2)+abs(h[idx]-h[idx+2]);

  ans = min(dp1,dp2);

  return ans;

}



void solve()

{

    cin >> n;

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

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

    int ans = solution(1);

    cout << ans;

}



signed main()

{

  IOS;

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

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

  int t=1;

  //cin >> t;

  while(t--)

  {

    solve();

  }

  return 0;

}

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


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

using namespace std;



typedef long long int ll;

typedef long double ld;



#define Pb push_back

#define Mp make_pair



#define ff first

#define ss second



#define Max(x,y,z) max(x,max(y,z))

#define Min(x,y,z) min(x,min(y,z))



#define INF LONG_LONG_MAX

#define MINF LONG_LONG_MIN



#define endl "\n"

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



#define db1(x) cout<<#x<<" : "<<x<<endl;

#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;

#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;



void solve()

{

    int n;

    cin >> n;

    int h[n];

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

    int dp[n];

    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]));

    }

    cout << dp[n-1];

}



signed main()

{

  IOS;

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

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

  int t=1;

  //cin >> t;

  while(t--)

  {

    solve();

  }

  return 0;

}

/*==============================================================================================================================================================*/
// Slower C++ solution:
//**KEEP IT SHORT AND SIMPLE**



#include <bits/stdc++.h>

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

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

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

#define NL '\n'

#define F first

#define S second

using namespace std;

typedef long long ll;

typedef bool bl;

typedef vector < vector<long long> > vvl;

typedef vector <long long> vll;

typedef pair <long long, long long> pll;

typedef set <long long> sll;

typedef map <long long, long long> mll;

typedef map <long long, bool> mlb;

typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;

double pi = 2 * acos(0.0);

int OO = 0x3f3f3f3f;

long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }

long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }

const int NMAX = 100010;;

ll n, arr[NMAX], dp[NMAX];

ll solve(ll i)

{

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

    if(~dp[i])      return dp[i];

    return dp[i] = min(solve(i + 1) + abs(arr[i + 1] - arr[i]), i + 2 <= n - 1 ? solve(i + 2) + abs(arr[i + 2] - arr[i]) : OO);

}

int main()

{

    IO

    cin >> n;

    REP(i, 0, n)    cin >> arr[i];

    memset(dp, -1, sizeof dp);

    cout << solve(0);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.7938541852523826x):
//**KEEP IT SHORT AND SIMPLE**



#include <bits/stdc++.h>

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

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

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

#define NL '\n'

#define F first

#define S second

#define dot(a, b) (conj(a) * (b)).real()

#define cross(a, b) (conj(a)* (b)).imag()

using namespace std;

typedef long long ll;

typedef long double ld;

typedef bool bl;

typedef vector < vector<long long> > vvl;

typedef vector <long long> vll;

typedef pair <long long, long long> pll;

typedef map <long long, long long> mll;

typedef map <long long, bool> mlb;

typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;

typedef tuple<ll, ll, ll> line;

typedef complex<double> point;

const double pi = 2 * acos(0.0);

const int OO = 0x3f3f3f3f;

int main()

{

    IO

    ll n;

    cin >> n;

    ll h[n], ans[n];

    REP(i, 0, n)    cin >> h[i];

    ans[0] = 0;

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

    REP(i, 2, n)    ans[i] = min(abs(h[i] - h[i - 1]) + ans[i - 1], abs(h[i - 2] - h[i]) + ans[i - 2]);

    cout << ans[n - 1];

    return 0;

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

using namespace std;

typedef long long int ll;

const int MAX=1e5+10;

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

int solve(int idx)

{

    if(idx==N)return 0;

    if(idx>N)return 1e9;

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

    return dp[idx]=min(abs(A[idx+1]-A[idx])+solve(idx+1),abs(A[idx+2]-A[idx])+solve(idx+2));

}

int  main ()

{

    memset(dp,-1,sizeof dp);

    cin >> N;

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

        cin >> A[i];

    }

    cout<<solve(1)<<endl;

    return 0;

}
// Slower C++ solution:
// Created by ahmed_drawy on 10/09/19.

///dp educational contest atcoder - vjudge

#include <bits/stdc++.h>

#include <string.h>

#pragma clang diagnostic push

#pragma ide diagnostic ignored "OCUnusedMacroInspection"

using namespace std;

#define lp(i,start , end)       for(int i = start ; i<end ; ++i)

#define lllp(i,start , end)       for(ll i = start ; i<end ; ++i)

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

#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)

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

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

#define clr(v,d)                memset(v , d , sizeof(v))

#define inf 0x3f3f3f3f

//#define dbg (v)    for(auto it : v)cout<<it<<' ';

typedef long long               ll;

typedef vector<int>             vi;

typedef vector  <ll>            vll;

typedef vector<vector<int> >    adj;

typedef pair<int ,int>          pii;

const double EPS =1e-7;

const int OO = 1e6;

#define endl '\n'

#define cint(c) (int)c -'0';

#define itc(c) (char)c +'A';

bool sortpair( const pair<int , int> & x, const pair<int , int> & y){

    return  x.first != y.first ? x.first < y.first : x.second > y.second ;

}

int dcomp(double x , double y){

    return fabs(x-y) <= EPS? 0: x>y?1:-1;

}



void smile() {

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

#ifndef ONLINE_JUDGE

//    freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);

//    freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);

#endif

}

#define fastin smile()



int n ;

const int N = 1e5 +3;

ll dp[N];

int h[N];

//ll solve(int indx , int state){

//    if(indx == n-1 )return 0 ;

//    ll &ret = dp[indx  ] [ state];

//    if(~ret )

//        return ret;

//    ret=  INT_MAX;

//    for (int i = 1; i <=2 && i+indx < n ; ++i) {

//        ret = min(ret , abs(h[indx]  - h[indx+ i])+solve(indx + i , i ));

//    }

//    return ret ;

//}

int main() {

    fastin;

    cin >> n;

    inN(h,  n );

    clr(dp , 0);

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

        if(j>=2){

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

        }

        else if(j ==1){

            dp[j] = abs(h[j] - h[j-1])+dp[j-1];

        }

    }

    cout << dp[n-1];

//

//    clr(dp , -1);

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

}

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

using namespace std;

typedef long long int ll;

const int MAX=1e5+10;

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

int solve(int idx)

{

    if(idx==N)return 0;

    if(idx>N)return 1e9;

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

    return dp[idx]=min(abs(A[idx+1]-A[idx])+solve(idx+1),abs(A[idx+2]-A[idx])+solve(idx+2));

}

int  main ()

{

    memset(dp,-1,sizeof dp);

    cin >> N;

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

        cin >> A[i];

    }

    cout<<solve(1)<<endl;

    return 0;

}
// 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: 2.616519157203369x):
#include <cstdio>

#include <cstdint>

#include <cinttypes>

#include <algorithm>

#include <cstring>



using i32 = std::int_fast32_t;

using i64 = std::int_fast64_t;



inline i32 diff(i32 x, i32 y) {

	return x > y ? x - y : y - x;

}



const int MaxN = 100001;



i32 A[MaxN], dp[MaxN];



signed main(signed argc, char **argv) {

	i32 n;

	scanf("%" SCNdFAST32, &n);



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

		scanf("%" SCNdFAST32, A + i);

	}



	memset(dp, 0x3f, sizeof dp);



	dp[0] = 0;

	dp[1] = diff(A[0], A[1]);

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

		dp[i] = std::min(dp[i - 1] + diff(A[i], A[i - 1]), dp[i - 2] + diff(A[i], A[i - 2]));

	}



	printf("%" SCNdFAST32, dp[n - 1]);

	return 0;

}
// Slower C++ solution:
// Created by ahmed_drawy on 10/09/19.

///dp educational contest atcoder - vjudge

#include <bits/stdc++.h>

#include <string.h>

#pragma clang diagnostic push

#pragma ide diagnostic ignored "OCUnusedMacroInspection"

using namespace std;

#define lp(i,start , end)       for(int i = start ; i<end ; ++i)

#define lllp(i,start , end)       for(ll i = start ; i<end ; ++i)

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

#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)

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

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

#define clr(v,d)                memset(v , d , sizeof(v))

#define inf 0x3f3f3f3f

//#define dbg (v)    for(auto it : v)cout<<it<<' ';

typedef long long               ll;

typedef vector<int>             vi;

typedef vector  <ll>            vll;

typedef vector<vector<int> >    adj;

typedef pair<int ,int>          pii;

const double EPS =1e-7;

const int OO = 1e6;

#define endl '\n'

#define cint(c) (int)c -'0';

#define itc(c) (char)c +'A';

bool sortpair( const pair<int , int> & x, const pair<int , int> & y){

    return  x.first != y.first ? x.first < y.first : x.second > y.second ;

}

int dcomp(double x , double y){

    return fabs(x-y) <= EPS? 0: x>y?1:-1;

}



void smile() {

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

#ifndef ONLINE_JUDGE

//    freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);

//    freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);

#endif

}

#define fastin smile()



int n ;

const int N = 1e5 +3;

ll dp[N];

int h[N];

//ll solve(int indx , int state){

//    if(indx == n-1 )return 0 ;

//    ll &ret = dp[indx  ] [ state];

//    if(~ret )

//        return ret;

//    ret=  INT_MAX;

//    for (int i = 1; i <=2 && i+indx < n ; ++i) {

//        ret = min(ret , abs(h[indx]  - h[indx+ i])+solve(indx + i , i ));

//    }

//    return ret ;

//}

int main() {

    fastin;

    cin >> n;

    inN(h,  n );

    clr(dp , 0);

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

        if(j>=2){

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

        }

        else if(j ==1){

            dp[j] = abs(h[j] - h[j-1])+dp[j-1];

        }

    }

    cout << dp[n-1];

//

//    clr(dp , -1);

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

}

// Faster C++ solution for the same problem (measured speedup: 1.8334721642685603x):
#include <cstdio>

#include <cstdint>

#include <cinttypes>

#include <algorithm>

#include <cstring>



using i32 = std::int_fast32_t;

using i64 = std::int_fast64_t;



inline i32 diff(i32 x, i32 y) {

	return x > y ? x - y : y - x;

}



const int MaxN = 100001;



i32 A[MaxN], dp[MaxN];



signed main(signed argc, char **argv) {

	i32 n;

	scanf("%" SCNdFAST32, &n);



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

		scanf("%" SCNdFAST32, A + i);

	}



	memset(dp, 0x3f, sizeof dp);



	dp[0] = 0;

	dp[1] = diff(A[0], A[1]);

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

		dp[i] = std::min(dp[i - 1] + diff(A[i], A[i - 1]), dp[i - 2] + diff(A[i], A[i - 2]));

	}



	printf("%" SCNdFAST32, dp[n - 1]);

	return 0;

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

using namespace std;

typedef long long int ll;

const int MAX=1e5+10;

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

int solve(int idx)

{

    if(idx==N)return 0;

    if(idx>N)return 1e9;

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

    return dp[idx]=min(abs(A[idx+1]-A[idx])+solve(idx+1),abs(A[idx+2]-A[idx])+solve(idx+2));

}

int  main ()

{

    memset(dp,-1,sizeof dp);

    cin >> N;

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

        cin >> A[i];

    }

    cout<<solve(1)<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.4101711925567837x):
#include <cstdio>

#include <cstdint>

#include <cinttypes>

#include <algorithm>

#include <cstring>



using i32 = std::int_fast32_t;

using i64 = std::int_fast64_t;



inline i32 diff(i32 x, i32 y) {

	return x > y ? x - y : y - x;

}



const int MaxN = 100001;



i32 A[MaxN], dp[MaxN];



signed main(signed argc, char **argv) {

	i32 n;

	scanf("%" SCNdFAST32, &n);



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

		scanf("%" SCNdFAST32, A + i);

	}



	memset(dp, 0x3f, sizeof dp);



	dp[0] = 0;

	dp[1] = diff(A[0], A[1]);

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

		dp[i] = std::min(dp[i - 1] + diff(A[i], A[i - 1]), dp[i - 2] + diff(A[i], A[i - 2]));

	}



	printf("%" SCNdFAST32, dp[n - 1]);

	return 0;

}
// 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: 2.5539677236972205x):
#include <cstring>

#include <iostream>

#include <string>

#include <vector>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <set>

#include <functional>

#include <numeric>

#include <utility>



#include <cmath>

#include <iomanip>



using namespace std;



int main()

{

  ios::sync_with_stdio(false);

  cin.tie(0);

  int n;

  cin >> n;

  int h[n];

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

    int cur;

    cin >> cur;

    h[i] = cur;

  }

  int minCosts[n];

  minCosts[0] = 0;

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

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

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

  }

  cout << minCosts[n-1] << "\n";

  return 0;

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

using namespace std;

typedef long long int ll;

const int MAX=1e5+10;

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

int solve(int idx)

{

    if(idx==N)return 0;

    if(idx>N)return 1e9;

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

    return dp[idx]=min(abs(A[idx+1]-A[idx])+solve(idx+1),abs(A[idx+2]-A[idx])+solve(idx+2));

}

int  main ()

{

    memset(dp,-1,sizeof dp);

    cin >> N;

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

        cin >> A[i];

    }

    cout<<solve(1)<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3764591406726376x):
#include <cstring>

#include <iostream>

#include <string>

#include <vector>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <set>

#include <functional>

#include <numeric>

#include <utility>



#include <cmath>

#include <iomanip>



using namespace std;



int main()

{

  ios::sync_with_stdio(false);

  cin.tie(0);

  int n;

  cin >> n;

  int h[n];

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

    int cur;

    cin >> cur;

    h[i] = cur;

  }

  int minCosts[n];

  minCosts[0] = 0;

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

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

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

  }

  cout << minCosts[n-1] << "\n";

  return 0;

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

#define LL long long

using namespace std;



//int cnt[26],cnt1[26];

int dp[100005];

int main(){

	int n;

	cin>>n;

	int ar[n];

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

		cin>>ar[i];

	}

	dp[0]=0;

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

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

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

	}

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

	return 0;

}
// Slower C++ solution:
// Created by ahmed_drawy on 10/09/19.

///dp educational contest atcoder - vjudge

#include <bits/stdc++.h>

#include <string.h>

#pragma clang diagnostic push

#pragma ide diagnostic ignored "OCUnusedMacroInspection"

using namespace std;

#define lp(i,start , end)       for(int i = start ; i<end ; ++i)

#define lllp(i,start , end)       for(ll i = start ; i<end ; ++i)

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

#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)

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

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

#define clr(v,d)                memset(v , d , sizeof(v))

#define inf 0x3f3f3f3f

//#define dbg (v)    for(auto it : v)cout<<it<<' ';

typedef long long               ll;

typedef vector<int>             vi;

typedef vector  <ll>            vll;

typedef vector<vector<int> >    adj;

typedef pair<int ,int>          pii;

const double EPS =1e-7;

const int OO = 1e6;

#define endl '\n'

#define cint(c) (int)c -'0';

#define itc(c) (char)c +'A';

bool sortpair( const pair<int , int> & x, const pair<int , int> & y){

    return  x.first != y.first ? x.first < y.first : x.second > y.second ;

}

int dcomp(double x , double y){

    return fabs(x-y) <= EPS? 0: x>y?1:-1;

}



void smile() {

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

#ifndef ONLINE_JUDGE

//    freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);

//    freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);

#endif

}

#define fastin smile()



int n ;

const int N = 1e5 +3;

ll dp[N];

int h[N];

//ll solve(int indx , int state){

//    if(indx == n-1 )return 0 ;

//    ll &ret = dp[indx  ] [ state];

//    if(~ret )

//        return ret;

//    ret=  INT_MAX;

//    for (int i = 1; i <=2 && i+indx < n ; ++i) {

//        ret = min(ret , abs(h[indx]  - h[indx+ i])+solve(indx + i , i ));

//    }

//    return ret ;

//}

int main() {

    fastin;

    cin >> n;

    inN(h,  n );

    clr(dp , 0);

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

        if(j>=2){

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

        }

        else if(j ==1){

            dp[j] = abs(h[j] - h[j-1])+dp[j-1];

        }

    }

    cout << dp[n-1];

//

//    clr(dp , -1);

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

}

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

#define LL long long

using namespace std;



//int cnt[26],cnt1[26];

int dp[100005];

int main(){

	int n;

	cin>>n;

	int ar[n];

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

		cin>>ar[i];

	}

	dp[0]=0;

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

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

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

	}

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

	return 0;

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

using namespace std;

typedef long long int ll;

const int MAX=1e5+10;

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

int solve(int idx)

{

    if(idx==N)return 0;

    if(idx>N)return 1e9;

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

    return dp[idx]=min(abs(A[idx+1]-A[idx])+solve(idx+1),abs(A[idx+2]-A[idx])+solve(idx+2));

}

int  main ()

{

    memset(dp,-1,sizeof dp);

    cin >> N;

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

        cin >> A[i];

    }

    cout<<solve(1)<<endl;

    return 0;

}


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

#define LL long long

using namespace std;



//int cnt[26],cnt1[26];

int dp[100005];

int main(){

	int n;

	cin>>n;

	int ar[n];

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

		cin>>ar[i];

	}

	dp[0]=0;

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

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

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

	}

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

	return 0;

}