stablegradients/pie-gem5-pairs huggingface dataset:
// 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: 1.791900642331696x):
#include <iostream>

#include <vector>

#include <cmath>

#include <set>

#include <queue>

#include <map>

#include <cstdio>

#include <cstring>

#include <string>

#include <stack>

#include <algorithm>

#include <limits.h>

#include <bits/stdc++.h>

#define fw(x) freopen("x.txt","w",stdout)

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

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

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

#define mem(a,s) memset(a,s,sizeof a)

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

#define pf printf

#define sc scanf

#define ll long long

#define pii pair<int,int>

#define pll pair<ll,ll>

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

#define vii vector<int>

#define vll vector<ll>

#define vss vector<string>

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

#define pb push_back





using namespace std;





// moves



//int dx[]= {0,0,1,-1};/*4 side move*/

//int dy[]= {-1,1,0,0};/*4 side move*/

//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/

//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/

//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/

//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/





//big_mod



//ll bigmod(ll a,ll b,ll m)

//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}

//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M



//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}

//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}

//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}

//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}



const int mod = 1000000007;

ll qpow(ll n,ll k)

{

    ll ans=1;

    assert(k>=0);

    n%=mod;

    while(k>0)

    {

        if(k&1)

            ans=(ans*n)%mod;

        n=(n*n)%mod;

        k>>=1;

    }

    return ans%mod;

}

int ar[100009];

int cost[100009];

void run(int i, int n){

    if(i>=n) return;

    if(cost[i]== -1 ){

        run(i+1, n);

        run(i+2, n);

    }

    if(i< n-1){

        int c1 = cost[i+1] + abs(ar[i]-ar[i+1]);

        int c2 = cost[i+2] + abs(ar[i]-ar[i+2]);

        cost[i] = min(c1, c2) ;

    }

    else cost[i] = cost[i+1] + abs(ar[i] - ar[i+1]);

}

int main()

{

    fast;

    int n, v;

    cin>>n;

    REP1(i, n){

        cin>>v;

        cost[i]= -1;

        ar[i] = v;

    }

    cost[n]=0;

    run(1, n);

    cout<<cost[1]<<'\n';

    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.3828448689858919x):
#include <iostream>

#include <vector>

#include <cmath>

#include <set>

#include <queue>

#include <map>

#include <cstdio>

#include <cstring>

#include <string>

#include <stack>

#include <algorithm>

#include <limits.h>

#include <bits/stdc++.h>

#define fw(x) freopen("x.txt","w",stdout)

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

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

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

#define mem(a,s) memset(a,s,sizeof a)

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

#define pf printf

#define sc scanf

#define ll long long

#define pii pair<int,int>

#define pll pair<ll,ll>

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

#define vii vector<int>

#define vll vector<ll>

#define vss vector<string>

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

#define pb push_back





using namespace std;





// moves



//int dx[]= {0,0,1,-1};/*4 side move*/

//int dy[]= {-1,1,0,0};/*4 side move*/

//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/

//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/

//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/

//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/





//big_mod



//ll bigmod(ll a,ll b,ll m)

//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}

//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M



//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}

//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}

//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}

//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}



const int mod = 1000000007;

ll qpow(ll n,ll k)

{

    ll ans=1;

    assert(k>=0);

    n%=mod;

    while(k>0)

    {

        if(k&1)

            ans=(ans*n)%mod;

        n=(n*n)%mod;

        k>>=1;

    }

    return ans%mod;

}

int ar[100009];

int cost[100009];

void run(int i, int n){

    if(i>=n) return;

    if(cost[i]== -1 ){

        run(i+1, n);

        run(i+2, n);

    }

    if(i< n-1){

        int c1 = cost[i+1] + abs(ar[i]-ar[i+1]);

        int c2 = cost[i+2] + abs(ar[i]-ar[i+2]);

        cost[i] = min(c1, c2) ;

    }

    else cost[i] = cost[i+1] + abs(ar[i] - ar[i+1]);

}

int main()

{

    fast;

    int n, v;

    cin>>n;

    REP1(i, n){

        cin>>v;

        cost[i]= -1;

        ar[i] = v;

    }

    cost[n]=0;

    run(1, n);

    cout<<cost[1]<<'\n';

    return 0;

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



using namespace std;

int v[100010];

int memo[100010];

int c;



int f(int i)

{



    if(memo[i]!=-1)

        return memo[i];



    if(i == 0)

        return memo[0] = 0;



    if(i == 1)

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



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

}



int main()

{

    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;

}

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

#include <vector>

#include <cmath>

#include <set>

#include <queue>

#include <map>

#include <cstdio>

#include <cstring>

#include <string>

#include <stack>

#include <algorithm>

#include <limits.h>

#include <bits/stdc++.h>

#define fw(x) freopen("x.txt","w",stdout)

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

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

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

#define mem(a,s) memset(a,s,sizeof a)

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

#define pf printf

#define sc scanf

#define ll long long

#define pii pair<int,int>

#define pll pair<ll,ll>

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

#define vii vector<int>

#define vll vector<ll>

#define vss vector<string>

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

#define pb push_back





using namespace std;





// moves



//int dx[]= {0,0,1,-1};/*4 side move*/

//int dy[]= {-1,1,0,0};/*4 side move*/

//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/

//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/

//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/

//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/





//big_mod



//ll bigmod(ll a,ll b,ll m)

//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}

//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M



//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}

//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}

//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}

//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}



const int mod = 1000000007;

ll qpow(ll n,ll k)

{

    ll ans=1;

    assert(k>=0);

    n%=mod;

    while(k>0)

    {

        if(k&1)

            ans=(ans*n)%mod;

        n=(n*n)%mod;

        k>>=1;

    }

    return ans%mod;

}

int ar[100009];

int cost[100009];

void run(int i, int n){

    if(i>=n) return;

    if(cost[i]== -1 ){

        run(i+1, n);

        run(i+2, n);

    }

    if(i< n-1){

        int c1 = cost[i+1] + abs(ar[i]-ar[i+1]);

        int c2 = cost[i+2] + abs(ar[i]-ar[i+2]);

        cost[i] = min(c1, c2) ;

    }

    else cost[i] = cost[i+1] + abs(ar[i] - ar[i+1]);

}

int main()

{

    fast;

    int n, v;

    cin>>n;

    REP1(i, n){

        cin>>v;

        cost[i]= -1;

        ar[i] = v;

    }

    cost[n]=0;

    run(1, n);

    cout<<cost[1]<<'\n';

    return 0;

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

using namespace std;

#define Me3za() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL))

#define endl "\n"

int n;

int arr[100005];

int mem[100005];

long long solve(int i,int cur){

if(i>=n)return 1e9;

//cout<<i<<" "<<cur<<endl;

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

long long ch1=solve(i+1,arr[i+1])+abs(cur-arr[i+1]);

long long ch2=0;

if(i+2<=n)ch2=solve(i+2,arr[i+2])+abs(cur-arr[i+2]);

return mem[i]=min(ch1,ch2);

}

int main() {

Me3za();

cin>>n;

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

    cin>>arr[i];

}

memset(mem,-1,sizeof mem);

cout<<solve(0,arr[0]);

}




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

#include <vector>

#include <cmath>

#include <set>

#include <queue>

#include <map>

#include <cstdio>

#include <cstring>

#include <string>

#include <stack>

#include <algorithm>

#include <limits.h>

#include <bits/stdc++.h>

#define fw(x) freopen("x.txt","w",stdout)

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

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

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

#define mem(a,s) memset(a,s,sizeof a)

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

#define pf printf

#define sc scanf

#define ll long long

#define pii pair<int,int>

#define pll pair<ll,ll>

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

#define vii vector<int>

#define vll vector<ll>

#define vss vector<string>

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

#define pb push_back





using namespace std;





// moves



//int dx[]= {0,0,1,-1};/*4 side move*/

//int dy[]= {-1,1,0,0};/*4 side move*/

//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/

//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/

//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/

//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/





//big_mod



//ll bigmod(ll a,ll b,ll m)

//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}

//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M



//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}

//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}

//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}

//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}



const int mod = 1000000007;

ll qpow(ll n,ll k)

{

    ll ans=1;

    assert(k>=0);

    n%=mod;

    while(k>0)

    {

        if(k&1)

            ans=(ans*n)%mod;

        n=(n*n)%mod;

        k>>=1;

    }

    return ans%mod;

}

int ar[100009];

int cost[100009];

void run(int i, int n){

    if(i>=n) return;

    if(cost[i]== -1 ){

        run(i+1, n);

        run(i+2, n);

    }

    if(i< n-1){

        int c1 = cost[i+1] + abs(ar[i]-ar[i+1]);

        int c2 = cost[i+2] + abs(ar[i]-ar[i+2]);

        cost[i] = min(c1, c2) ;

    }

    else cost[i] = cost[i+1] + abs(ar[i] - ar[i+1]);

}

int main()

{

    fast;

    int n, v;

    cin>>n;

    REP1(i, n){

        cin>>v;

        cost[i]= -1;

        ar[i] = v;

    }

    cost[n]=0;

    run(1, n);

    cout<<cost[1]<<'\n';

    return 0;

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



using namespace std;



const int N=1e5;

int n;

int arr[N];

int mem[N];



int solve(int i){

    if(i==n-1)

        return 0;

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

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

    int op2=i+2<=n-1?solve(i+2)+abs(arr[i]-arr[i+2]):1000000000;

    return mem[i]=min(op1,op2);

}



int main() {

    scanf("%d",&n);

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

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

    memset(mem,-1,sizeof mem);

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

    return 0;

}


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

#include <vector>

#include <cmath>

#include <set>

#include <queue>

#include <map>

#include <cstdio>

#include <cstring>

#include <string>

#include <stack>

#include <algorithm>

#include <limits.h>

#include <bits/stdc++.h>

#define fw(x) freopen("x.txt","w",stdout)

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

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

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

#define mem(a,s) memset(a,s,sizeof a)

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

#define pf printf

#define sc scanf

#define ll long long

#define pii pair<int,int>

#define pll pair<ll,ll>

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

#define vii vector<int>

#define vll vector<ll>

#define vss vector<string>

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

#define pb push_back





using namespace std;





// moves



//int dx[]= {0,0,1,-1};/*4 side move*/

//int dy[]= {-1,1,0,0};/*4 side move*/

//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/

//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/

//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/

//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/





//big_mod



//ll bigmod(ll a,ll b,ll m)

//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}

//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M



//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}

//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}

//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}

//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}



const int mod = 1000000007;

ll qpow(ll n,ll k)

{

    ll ans=1;

    assert(k>=0);

    n%=mod;

    while(k>0)

    {

        if(k&1)

            ans=(ans*n)%mod;

        n=(n*n)%mod;

        k>>=1;

    }

    return ans%mod;

}

int ar[100009];

int cost[100009];

void run(int i, int n){

    if(i>=n) return;

    if(cost[i]== -1 ){

        run(i+1, n);

        run(i+2, n);

    }

    if(i< n-1){

        int c1 = cost[i+1] + abs(ar[i]-ar[i+1]);

        int c2 = cost[i+2] + abs(ar[i]-ar[i+2]);

        cost[i] = min(c1, c2) ;

    }

    else cost[i] = cost[i+1] + abs(ar[i] - ar[i+1]);

}

int main()

{

    fast;

    int n, v;

    cin>>n;

    REP1(i, n){

        cin>>v;

        cost[i]= -1;

        ar[i] = v;

    }

    cost[n]=0;

    run(1, n);

    cout<<cost[1]<<'\n';

    return 0;

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

using namespace std;

int abssub(int a,int b){

	if(a>b)return a-b;

	return b-a;

}

int main(){

	int n,h[100001],bp[100001]={0};

	cin>>n; 

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

		cin>>h[i];

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

		if(i==2)bp[i]=bp[i-1]+abssub(h[i],h[i-1]);

		else{

			bp[i]=min(bp[i-1]+abssub(h[i],h[i-1]),bp[i-2]+abssub(h[i],h[i-2]));

		}

	}

	cout<<bp[n]<<endl;

	return 0;

}

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

#include <vector>

#include <cmath>

#include <set>

#include <queue>

#include <map>

#include <cstdio>

#include <cstring>

#include <string>

#include <stack>

#include <algorithm>

#include <limits.h>

#include <bits/stdc++.h>

#define fw(x) freopen("x.txt","w",stdout)

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

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

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

#define mem(a,s) memset(a,s,sizeof a)

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

#define pf printf

#define sc scanf

#define ll long long

#define pii pair<int,int>

#define pll pair<ll,ll>

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

#define vii vector<int>

#define vll vector<ll>

#define vss vector<string>

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

#define pb push_back





using namespace std;





// moves



//int dx[]= {0,0,1,-1};/*4 side move*/

//int dy[]= {-1,1,0,0};/*4 side move*/

//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/

//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/

//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/

//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/





//big_mod



//ll bigmod(ll a,ll b,ll m)

//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}

//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M



//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}

//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}

//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}

//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}



const int mod = 1000000007;

ll qpow(ll n,ll k)

{

    ll ans=1;

    assert(k>=0);

    n%=mod;

    while(k>0)

    {

        if(k&1)

            ans=(ans*n)%mod;

        n=(n*n)%mod;

        k>>=1;

    }

    return ans%mod;

}

int ar[100009];

int cost[100009];

void run(int i, int n){

    if(i>=n) return;

    if(cost[i]== -1 ){

        run(i+1, n);

        run(i+2, n);

    }

    if(i< n-1){

        int c1 = cost[i+1] + abs(ar[i]-ar[i+1]);

        int c2 = cost[i+2] + abs(ar[i]-ar[i+2]);

        cost[i] = min(c1, c2) ;

    }

    else cost[i] = cost[i+1] + abs(ar[i] - ar[i+1]);

}

int main()

{

    fast;

    int n, v;

    cin>>n;

    REP1(i, n){

        cin>>v;

        cost[i]= -1;

        ar[i] = v;

    }

    cost[n]=0;

    run(1, n);

    cout<<cost[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.55843991344605x):
#include <bits/stdc++.h>

#define ll long long

#define str string

#define fori(i,n) for(long long i=1;i<=n;i++)

#define forj(j,n) for(long long j=1;j<=n;j++)

#define fors(i,ssz) for(long long i=0;i<s.size();i++)

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

using namespace std;

ll n,dp[100001],h[100001],maxi;

int main(){

	Need_for_Speed

	cin>>n;

	fori(i,n)

	cin>>h[i];

	dp[1]=0;

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

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

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

	}

	cout<<dp[n]<<endl;

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

#define ll long long

#define str string

#define fori(i,n) for(long long i=1;i<=n;i++)

#define forj(j,n) for(long long j=1;j<=n;j++)

#define fors(i,ssz) for(long long i=0;i<s.size();i++)

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

using namespace std;

ll n,dp[100001],h[100001],maxi;

int main(){

	Need_for_Speed

	cin>>n;

	fori(i,n)

	cin>>h[i];

	dp[1]=0;

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

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

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

	}

	cout<<dp[n]<<endl;

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

#define ll long long

#define str string

#define fori(i,n) for(long long i=1;i<=n;i++)

#define forj(j,n) for(long long j=1;j<=n;j++)

#define fors(i,ssz) for(long long i=0;i<s.size();i++)

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

using namespace std;

ll n,dp[100001],h[100001],maxi;

int main(){

	Need_for_Speed

	cin>>n;

	fori(i,n)

	cin>>h[i];

	dp[1]=0;

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

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

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

	}

	cout<<dp[n]<<endl;

}