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: 1.3557240477364687x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

}
// 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: 2.5386382941336905x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

}
// 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: 1.7713251666676177x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

}
// 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.768436053601087x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

}
// 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.3647367856678545x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

}
// 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: 1.7441096210517641x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

}
// 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.3803964968528883x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

}
// 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.375768266418541x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

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

using namespace std;



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



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<=n-3) ? solve(i+2)+abs(arr[i]-arr[i+2]) : OO;

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

}





int main()

{

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

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

    scanf("%d",&n);

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

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

    memset(mem, -1, sizeof mem);

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



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3525294857971444x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

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



using namespace std;

typedef long long ll;

typedef double dd;

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

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {

    cin.tie(0);

    cin.sync_with_stdio(0);

}



const int N = 1e5 + 9;

int n, h[N], dp[N];



int sol(int i){

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

    if(i == n)  return 1e9;



    int &ret = dp[i];

    if(~ret)    return ret;



    return ret = min(abs(h[i] - h[i + 1]) + sol(i + 1), abs(h[i] - h[i + 2]) + sol(i + 2));

}





int main() {



    cin >> n;



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



    memset(dp, -1, sizeof dp);



    cout << sol(0);

}

// Faster C++ solution for the same problem (measured speedup: 1.3628825467338739x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

}
// 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.3521965249277434x):
#define _CRT_SECURE_NO_WARINGS

#include<iostream>

#include<iomanip>

#include<map>

#include<cmath>

#include<algorithm>

#include<string>

#include<vector>

#include<queue>

#include<set>

#include<deque>

#include<stack>

#include<bitset>

#include<fstream>

#include<map>

#include<unordered_map>

using namespace std;

typedef int me;

typedef long long ll;

typedef unsigned long long ull;

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

#define endl '\n'

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

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

#define PI 3.1415926535

#define sin(i) (long double)sin(i*PI/180.0);

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }

ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void the_end() {

#ifndef ONLINE_JUDGE;

    system("pause");

#endif

}

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };

int dx8[] = { 1,-1,0,0,1,-1,1,-1 };

int id8[] = { 0, 1,2,3,4, 5,6, 7 };

// you can be specialist 

// soon will be (Cyain)

ll n;

vector<ll>v;

map<int, ll>m;

ll solve(int i)

{

    if (i == 0)

        return 0;

    if (i == 1) {

        return abs(v[i] - v[i - 1]);

    }

    if (m.find(i) != m.end())

        return m[i];

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

}

int main()

{

    andrew;

    cin >> n;

    v.resize(n);

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

    cout << solve(n-1)<< endl;

    the_end();

}