stablegradients/pie-gem5-pairs huggingface dataset:
// 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;

/*ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }

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

*void exEuclid(int a, int b){

	if(b==0){x = 1; y=0; d=a; return ;}

	exEuclid(b, a%b);

	int x1=y;

	int y1=x-(a/b)*y;

	x=x1;

	y=y1;

} 

* */

//===========================================================//

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

using namespace std;

#define ll long long

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

#define vi vector<ll>

#define vvi vector<vi>

#define Q queue<ll>

#define DQ deque<ll> 

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back

#define mp make_pair

#define mt make_tuple

#define f first

#define s second

#define ub upper_bound

#define lb lower_bound

#define loop(x,y,z) for(ll i=x; i<=y; i+=z)

#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)

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

#define sum(x) accumulate(all(x),0LL)

#define minE(x) *min_element(all(x))

#define maxE(x) *max_element(all(x))

#define watch(x) cout<<(#x)<<" is "<<x

#define endl "\n"



ll gcd(ll a, ll b){

	return (!b)?a:gcd(b,a%b);

}



void display(vi &v,string c){

	for(auto x:v) cout<<x<<c;

}



int main(){

	IOS

	ll t;

	cin>>t;

	vi v(t),dp(t);

	loop(0,t-1,1) cin>>v[i];

	dp[0]=0;

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

	loop(2,t-1,1){

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

	}

	cout<<dp[t-1];

	return 0;

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

using namespace std;

typedef long long ll;

ll dp[100009];

int arr[100009];

ll sum = 0;

long long Frog1(int n){

 

    if(n==0) return 0;

    else if(n==1) return abs(arr[n] - arr[n-1]);

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

    else {

            ll x = Frog1(n-1);

            ll y = Frog1(n-2);

        dp[n] = min(abs (arr[n-1] - arr[n]) + x,abs(arr[n-2] - arr[n]) + y);

        //cout << n << " = " << dp[n] << endl;

         return dp[n];

    }

}

 

 

int main()

{

    int n;

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

    cin >> n;

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

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

}

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

using namespace std;

#define ll long long

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

#define vi vector<ll>

#define vvi vector<vi>

#define Q queue<ll>

#define DQ deque<ll> 

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back

#define mp make_pair

#define mt make_tuple

#define f first

#define s second

#define ub upper_bound

#define lb lower_bound

#define loop(x,y,z) for(ll i=x; i<=y; i+=z)

#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)

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

#define sum(x) accumulate(all(x),0LL)

#define minE(x) *min_element(all(x))

#define maxE(x) *max_element(all(x))

#define watch(x) cout<<(#x)<<" is "<<x

#define endl "\n"



ll gcd(ll a, ll b){

	return (!b)?a:gcd(b,a%b);

}



void display(vi &v,string c){

	for(auto x:v) cout<<x<<c;

}



int main(){

	IOS

	ll t;

	cin>>t;

	vi v(t),dp(t);

	loop(0,t-1,1) cin>>v[i];

	dp[0]=0;

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

	loop(2,t-1,1){

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

	}

	cout<<dp[t-1];

	return 0;

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

using namespace std;

#define ll long long

#define ld long double

#define sf scanf

#define pf printf

#define pb push_back

#define llu unsigned long long

#define U unsigned int

#define SIZE 1000002

#define pie 3.14159265358979323

#define minuss 1e-6

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

 

#define BIG 100000000

 

ll  lcm(ll a,ll b)

{

    ll GCD=__gcd(a,b);

    ll lcm=(a*b)/GCD;

    return lcm;

}

ll dp[100005];

ll weight[1000005],value[1000005];

ll total,val;

ll call(ll n)

{

    if(n>=total)

        return 0;

 

    if(dp[n]!=-1)

        return dp[n];

 

    ll res1=BIG,res2=BIG;

 

   // if(weight[n]+c<=val)

    res1=abs(weight[n]-weight[n+1]) + call(n+1);

    if(n+2<=total) res2=abs(weight[n]-weight[n+2]) + call(n+2);

    //cout<<n<<" "<<res1<<" "<<res2<<endl;

    dp[n]=min(res1,res2);

    return dp[n];

 

}

int main()

{

    cin>>total;

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

        cin>>weight[i];

 

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

    ll ret=call(1);

    cout<<ret<<endl;

    return 0;

}

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

using namespace std;

#define ll long long

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

#define vi vector<ll>

#define vvi vector<vi>

#define Q queue<ll>

#define DQ deque<ll> 

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back

#define mp make_pair

#define mt make_tuple

#define f first

#define s second

#define ub upper_bound

#define lb lower_bound

#define loop(x,y,z) for(ll i=x; i<=y; i+=z)

#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)

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

#define sum(x) accumulate(all(x),0LL)

#define minE(x) *min_element(all(x))

#define maxE(x) *max_element(all(x))

#define watch(x) cout<<(#x)<<" is "<<x

#define endl "\n"



ll gcd(ll a, ll b){

	return (!b)?a:gcd(b,a%b);

}



void display(vi &v,string c){

	for(auto x:v) cout<<x<<c;

}



int main(){

	IOS

	ll t;

	cin>>t;

	vi v(t),dp(t);

	loop(0,t-1,1) cin>>v[i];

	dp[0]=0;

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

	loop(2,t-1,1){

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

	}

	cout<<dp[t-1];

	return 0;

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

using namespace std;



int num[100001], memo[100001];



int dp(int n){

    if(n==0) return 0;

    if(n==1) return abs(num[0]-num[1]);

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

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

}



int main(){

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

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

    ios_base::sync_with_stdio(0);

    cin.tie(0);

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

    int n;

    cin>>n;

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

    cout<<dp(n-1)<<"\n";

    return 0;

}


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

using namespace std;

#define ll long long

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

#define vi vector<ll>

#define vvi vector<vi>

#define Q queue<ll>

#define DQ deque<ll> 

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back

#define mp make_pair

#define mt make_tuple

#define f first

#define s second

#define ub upper_bound

#define lb lower_bound

#define loop(x,y,z) for(ll i=x; i<=y; i+=z)

#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)

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

#define sum(x) accumulate(all(x),0LL)

#define minE(x) *min_element(all(x))

#define maxE(x) *max_element(all(x))

#define watch(x) cout<<(#x)<<" is "<<x

#define endl "\n"



ll gcd(ll a, ll b){

	return (!b)?a:gcd(b,a%b);

}



void display(vi &v,string c){

	for(auto x:v) cout<<x<<c;

}



int main(){

	IOS

	ll t;

	cin>>t;

	vi v(t),dp(t);

	loop(0,t-1,1) cin>>v[i];

	dp[0]=0;

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

	loop(2,t-1,1){

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

	}

	cout<<dp[t-1];

	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()

{



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

using namespace std;

#define ll long long

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

#define vi vector<ll>

#define vvi vector<vi>

#define Q queue<ll>

#define DQ deque<ll> 

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back

#define mp make_pair

#define mt make_tuple

#define f first

#define s second

#define ub upper_bound

#define lb lower_bound

#define loop(x,y,z) for(ll i=x; i<=y; i+=z)

#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)

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

#define sum(x) accumulate(all(x),0LL)

#define minE(x) *min_element(all(x))

#define maxE(x) *max_element(all(x))

#define watch(x) cout<<(#x)<<" is "<<x

#define endl "\n"



ll gcd(ll a, ll b){

	return (!b)?a:gcd(b,a%b);

}



void display(vi &v,string c){

	for(auto x:v) cout<<x<<c;

}



int main(){

	IOS

	ll t;

	cin>>t;

	vi v(t),dp(t);

	loop(0,t-1,1) cin>>v[i];

	dp[0]=0;

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

	loop(2,t-1,1){

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

	}

	cout<<dp[t-1];

	return 0;

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



using namespace std;



const int N = 1e5 + 9;



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



int solve(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]) + solve(i + 1), abs(h[i] - h[i + 2]) + solve(i + 2));

}



int main(){



    cin >> n;

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

        cin >> h[i];



    memset(dp, -1, sizeof dp);



    cout << solve(0);

}


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

using namespace std;

#define ll long long

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

#define vi vector<ll>

#define vvi vector<vi>

#define Q queue<ll>

#define DQ deque<ll> 

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back

#define mp make_pair

#define mt make_tuple

#define f first

#define s second

#define ub upper_bound

#define lb lower_bound

#define loop(x,y,z) for(ll i=x; i<=y; i+=z)

#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)

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

#define sum(x) accumulate(all(x),0LL)

#define minE(x) *min_element(all(x))

#define maxE(x) *max_element(all(x))

#define watch(x) cout<<(#x)<<" is "<<x

#define endl "\n"



ll gcd(ll a, ll b){

	return (!b)?a:gcd(b,a%b);

}



void display(vi &v,string c){

	for(auto x:v) cout<<x<<c;

}



int main(){

	IOS

	ll t;

	cin>>t;

	vi v(t),dp(t);

	loop(0,t-1,1) cin>>v[i];

	dp[0]=0;

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

	loop(2,t-1,1){

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

	}

	cout<<dp[t-1];

	return 0;

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

using namespace std;

int n;

long long h[100005];

long long dp[100005];



long long solve(int i){

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

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



	dp[i] = 1e17;

	if(i+1 <= n-1)

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

	if(i+2 <= n-1)

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



	return dp[i];

}



int main(){

	scanf("%d", &n);

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

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

	memset(dp, -1, sizeof dp);

	cout<<solve(0)<<endl;

	return 0;

}

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

using namespace std;

#define ll long long

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

#define vi vector<ll>

#define vvi vector<vi>

#define Q queue<ll>

#define DQ deque<ll> 

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back

#define mp make_pair

#define mt make_tuple

#define f first

#define s second

#define ub upper_bound

#define lb lower_bound

#define loop(x,y,z) for(ll i=x; i<=y; i+=z)

#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)

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

#define sum(x) accumulate(all(x),0LL)

#define minE(x) *min_element(all(x))

#define maxE(x) *max_element(all(x))

#define watch(x) cout<<(#x)<<" is "<<x

#define endl "\n"



ll gcd(ll a, ll b){

	return (!b)?a:gcd(b,a%b);

}



void display(vi &v,string c){

	for(auto x:v) cout<<x<<c;

}



int main(){

	IOS

	ll t;

	cin>>t;

	vi v(t),dp(t);

	loop(0,t-1,1) cin>>v[i];

	dp[0]=0;

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

	loop(2,t-1,1){

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

	}

	cout<<dp[t-1];

	return 0;

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

using namespace std;

#define ll long long

#define pb push_back

#define mp make_pair

#define ull  unsigned long long

#define vll  vector <long long>

#define pll pair <long long,long long>

#define f first

#define s second

#define up upper_bound

#define lp lower_bound

#define pq priority_queue

#define inf 1e10

#define minf -1e10

#define pi 3.14159265

#define mod 300000000000000000

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

int main()

{

    ll n;

    cin>>n;

    vll vec;

    ll ara[100001];

    memset(ara,0,sizeof(ara));

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

    {

        ll num;

        cin>>num;

        vec.pb(num);

    }

    ll ans=0;

    ara[n-2]=abs(vec[n-2]-vec[n-1]);

    for(ll i=n-3;i>=0;i--)

    {

        ara[i]=min(abs(vec[i]-vec[i+1])+ara[i+1],abs(vec[i]-vec[i+2])+ara[i+2]);

    }

    cout<<ara[0]<<endl;

}


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

using namespace std;

#define ll long long

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

#define vi vector<ll>

#define vvi vector<vi>

#define Q queue<ll>

#define DQ deque<ll> 

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back

#define mp make_pair

#define mt make_tuple

#define f first

#define s second

#define ub upper_bound

#define lb lower_bound

#define loop(x,y,z) for(ll i=x; i<=y; i+=z)

#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)

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

#define sum(x) accumulate(all(x),0LL)

#define minE(x) *min_element(all(x))

#define maxE(x) *max_element(all(x))

#define watch(x) cout<<(#x)<<" is "<<x

#define endl "\n"



ll gcd(ll a, ll b){

	return (!b)?a:gcd(b,a%b);

}



void display(vi &v,string c){

	for(auto x:v) cout<<x<<c;

}



int main(){

	IOS

	ll t;

	cin>>t;

	vi v(t),dp(t);

	loop(0,t-1,1) cin>>v[i];

	dp[0]=0;

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

	loop(2,t-1,1){

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

	}

	cout<<dp[t-1];

	return 0;

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

using namespace std;

#define ll long long



int ara[100000];

int dp[100000];



int f(int i, int n)

{

    if(i == n) return 0;

    if(dp[i] != -1)

        return dp[i];

    int cost = f(i+1,n) + abs(ara[i] - ara[i+1]);

    if(i+2<=n)

        cost = min(cost, f(i+2,n)+abs(ara[i] - ara[i+2]));

    dp[i] = cost;



    return cost;

}



int main()

{

   int n;

   cin>>n;



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

   {

       cin>>ara[i];

   }



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

   cout<<f(1,n)<<endl;



   return 0;

}






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

using namespace std;

#define ll long long

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

#define vi vector<ll>

#define vvi vector<vi>

#define Q queue<ll>

#define DQ deque<ll> 

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back

#define mp make_pair

#define mt make_tuple

#define f first

#define s second

#define ub upper_bound

#define lb lower_bound

#define loop(x,y,z) for(ll i=x; i<=y; i+=z)

#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)

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

#define sum(x) accumulate(all(x),0LL)

#define minE(x) *min_element(all(x))

#define maxE(x) *max_element(all(x))

#define watch(x) cout<<(#x)<<" is "<<x

#define endl "\n"



ll gcd(ll a, ll b){

	return (!b)?a:gcd(b,a%b);

}



void display(vi &v,string c){

	for(auto x:v) cout<<x<<c;

}



int main(){

	IOS

	ll t;

	cin>>t;

	vi v(t),dp(t);

	loop(0,t-1,1) cin>>v[i];

	dp[0]=0;

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

	loop(2,t-1,1){

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

	}

	cout<<dp[t-1];

	return 0;

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



#define TR 100000



int l[TR];

using namespace std;

vector<int> h;





int solve(int p) {

	if(p == 0)

		return 0;

	if(p < 0)

		return 10000000;

	if(l[p] != -1)

		return l[p];

	l[p] = min(abs(h[p] - h[p - 1]) + solve(p - 1), abs(h[p] - h[p - 2]) + solve(p - 2));

	return l[p];



}



int main() {

	int n;

	cin >> n;

	memset(l, -1, TR * sizeof(int));

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

		cin >> tmp;

		h.push_back(tmp);

	}

	solve(n - 1);

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

}

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

using namespace std;

#define ll long long

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

#define vi vector<ll>

#define vvi vector<vi>

#define Q queue<ll>

#define DQ deque<ll> 

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back

#define mp make_pair

#define mt make_tuple

#define f first

#define s second

#define ub upper_bound

#define lb lower_bound

#define loop(x,y,z) for(ll i=x; i<=y; i+=z)

#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)

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

#define sum(x) accumulate(all(x),0LL)

#define minE(x) *min_element(all(x))

#define maxE(x) *max_element(all(x))

#define watch(x) cout<<(#x)<<" is "<<x

#define endl "\n"



ll gcd(ll a, ll b){

	return (!b)?a:gcd(b,a%b);

}



void display(vi &v,string c){

	for(auto x:v) cout<<x<<c;

}



int main(){

	IOS

	ll t;

	cin>>t;

	vi v(t),dp(t);

	loop(0,t-1,1) cin>>v[i];

	dp[0]=0;

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

	loop(2,t-1,1){

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

	}

	cout<<dp[t-1];

	return 0;

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

using namespace std;

#define N (int)2e5

int n,memo[N],c[N];



int dp(int curr) {

    if (curr == n) return 0;

    if (curr > n) return 1e9;

    int &sol = memo[curr];

    if (sol != -1) return sol;

    sol = min(

        dp(curr + 1) + abs(c[curr] - c[curr + 1]) ,

        dp(curr + 2) + abs(c[curr] - c[curr + 2])

    );

    return sol;

}



int main() {

    scanf("%d" , &n);

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

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

    memset (memo , -1 , sizeof memo);

    printf("%d\n" , dp(1));

}


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

using namespace std;

const int inf=0x3f3f3f3f;

void A()

{

    int n;

    cin>>n;

    vector<int> a(n,0);

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

    vector<int> dp(n+1,inf);

    dp[0]=0;

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

        dp[i]=min(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-1]<<endl;



}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    A();

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

#include<map>

#include<cmath>

#include<ctime>

#include<queue>

#include<stack>

#include<cstdio>

#include<string>

#include<vector>

#include<random>

#include<cstdlib>

#include<cstring>

#include<iomanip>

#include<iostream>

#include<algorithm>

#include<unordered_map>

#define endl "\n"

#define fi first

#define se second

#define db double

#define gcd __gcd

#define pb push_back

#define mp make_pair

#define lowbit(x) (x & (-x))

#define PII  pair<int, int> 

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

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

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

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

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

template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }

template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }

typedef long long ll;

typedef unsigned long long ull;

const db eps = 1e-9;

const db PI = acos(-1);

const int inf = 0x3f3f3f3f;

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

const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE

const ll INF = 0x3f3f3f3f3f3f3f3f;

using namespace std;

ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }



inline int read(){

	char ch = getchar();

	int x = 0, f = 1;

	while(ch < '0' || ch > '9'){

		if(ch == '-') f = -1;

		ch = getchar();

	}

	while('0' <= ch && ch <= '9'){

		x = x * 10 + ch - '0';

		ch = getchar();

	}

	return x * f;

}



int n;

int h[maxn], dp[maxn];



int main()

{

	n = read();

	rep(i, 1, n) h[i] = read();

	memset(dp, 0x3f, sizeof dp);

	dp[1] = 0;

	rep(i, 1, n){

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

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

	}

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

	return 0;

}

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

using namespace std;

const int inf=0x3f3f3f3f;

void A()

{

    int n;

    cin>>n;

    vector<int> a(n,0);

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

    vector<int> dp(n+1,inf);

    dp[0]=0;

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

        dp[i]=min(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-1]<<endl;



}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    A();

}