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

#include <string>

#include <cstring>

#include <stdlib.h>

#include <math.h>

#include <algorithm>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <list>

#include <iterator>

#include <assert.h>

#pragma warning(disable:4996) 

 

typedef long long ll;

#define MIN(a, b) ((a)>(b)? (b): (a))

#define MAX(a, b) ((a)<(b)? (b): (a))

#define LINF 9223300000000000000

#define INF 2140000000

const long long MOD = 1000000007;

//const long long MOD = 998244353;



using namespace std;





void solve()

{

    int n, T;

    scanf("%d%d", &n, &T);

    vector<int> a(n);

    int i;

    ll sum = 0;

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

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

        if (i > 0) sum += MIN(T, a[i] - a[i - 1]);

    }

    printf("%lld\n", sum+T);

    return;

}



int main(int argc, char* argv[])

{

#if 1

    solve();

#else

    int T; scanf("%d", &T);

    while(T--) {

        solve();

    }

#endif

    return 0;

}


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

#include <string>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <list>

#include <iterator>

#include <cassert>

#include <numeric>

#include <functional>

#include <cassert>

//#include <numeric>

#pragma warning(disable:4996) 

 

typedef long long ll;

typedef unsigned long long ull;

#define MIN(a, b) ((a)>(b)? (b): (a))

#define MAX(a, b) ((a)<(b)? (b): (a))

#define LINF  9223300000000000000

#define LINF2 1223300000000000000

#define INF 2140000000

const long long MOD = 1000000007;

//const long long MOD = 998244353;



using namespace std;







void solve()

{

    int n, T;

    scanf("%d%d", &n, &T);

    int i;

    int prev = -1;

    ll sum = 0;

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

        int tmp;

        scanf("%d", &tmp);

        if (i > 0) {

            if (tmp > prev + T) {

                sum += T;

            }

            else {

                sum += (tmp - prev);

            }

        }

        prev = tmp;

    }

    printf("%lld\n", sum + T);



    return;

}



int main(int argc, char* argv[])

{

#if 1

    solve();

#else

    int T;

    scanf("%d", &T);

    int t;

    for(t=0; t<T; t++) {

        //printf("Case #%d: ", t+1);

        solve();

    }

#endif

    return 0;

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

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<algorithm>

#include<iostream>

using namespace std;

int main(){

	long long n,T,t[200000];

	long long sum=0;

	cin>>n>>T;

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

		cin>>t[i];

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

		if(t[i]-t[i-1]>=T)

			sum+=T;

		else

			sum+=t[i]-t[i-1];

	}

	sum+=T;

	cout<<sum<<endl;

}








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

int main()

{

	int a[200005];

	int b[200005];

	int n, i, t;

	scanf("%d %d", &n, &t);

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

	{

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

		b[i] = a[i] + t;

	}

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

	{

		if(b[i] > a[i + 1])

		{

			a[i + 1] = b[i];

		}

	}

	int sum = 0;

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

	{

		sum = sum + b[i] - a[i];

	}

	printf("%d\n",sum);

	return 0;

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

#include<cmath>

#include<cstring>

#include<iostream>

#include<cstdlib>

#include<algorithm>

#include<map>

using namespace std;



int n, t;

int a[200005];

int main()

{

	scanf("%d%d", &n, &t);

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

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

	long long sum = 0;

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

	{

		int ant = a[i] - a[i-1];

		if(ant < t) sum += ant;

		else sum += t;

	}

	printf("%lld\n", sum + t);

}


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

int main()

{

	int a[200005];

	int b[200005];

	int n, i, t;

	scanf("%d %d", &n, &t);

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

	{

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

		b[i] = a[i] + t;

	}

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

	{

		if(b[i] > a[i + 1])

		{

			a[i + 1] = b[i];

		}

	}

	int sum = 0;

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

	{

		sum = sum + b[i] - a[i];

	}

	printf("%d\n",sum);

	return 0;

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

using namespace std;

int n,t,a[200005],l,r,j;

long long s;

int main()

{

	cin>>n>>t;

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

	{

		cin>>a[i];

	}



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

	{

	  if(i==n)s+=t;

	  else if(a[i+1]-a[i]<=t)s=s+a[i+1]-a[i];

	  else if(a[i+1]-a[i]>t)s+=t;

	}

	cout<<s;

	return 0;

}

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

int main()

{

	int a[200005];

	int b[200005];

	int n, i, t;

	scanf("%d %d", &n, &t);

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

	{

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

		b[i] = a[i] + t;

	}

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

	{

		if(b[i] > a[i + 1])

		{

			a[i + 1] = b[i];

		}

	}

	int sum = 0;

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

	{

		sum = sum + b[i] - a[i];

	}

	printf("%d\n",sum);

	return 0;

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

    #include<cstring>

    #include<cstdio>

    #include<cstdlib>

    #include<algorithm>

    #include<map>

    #include<cmath>

    #include<cstdlib>

    using namespace std;

    const int M=200005;

long long int n,m,flag,sum;

int a[M];

int main()

{

   cin>>n>>m;

   cin>>a[1];

   sum=0;

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

   {

        cin>>a[i];

        if(a[i]-a[i-1]>=m)

            sum+=m;

        else if(a[i]-a[i-1]<m)

            sum+=a[i]-a[i-1];

   }

   sum+=m;

   cout<<sum<<endl;

}


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

int main()

{

	int a[200005];

	int b[200005];

	int n, i, t;

	scanf("%d %d", &n, &t);

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

	{

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

		b[i] = a[i] + t;

	}

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

	{

		if(b[i] > a[i + 1])

		{

			a[i + 1] = b[i];

		}

	}

	int sum = 0;

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

	{

		sum = sum + b[i] - a[i];

	}

	printf("%d\n",sum);

	return 0;

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

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<algorithm>

#include<iostream>

using namespace std;

int main(){

	long long n,T,t[200000];

	long long sum=0;

	cin>>n>>T;

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

		cin>>t[i];

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

		if(t[i]-t[i-1]>=T)

			sum+=T;

		else

			sum+=t[i]-t[i-1];

	}

	sum+=T;

	cout<<sum<<endl;

}








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

using namespace std;

const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

	for(int i = 1; i <= N; i++)	scanf("%lld", &a[i]);

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

	{

		if(a[i] <= T)

		{

			flag = a[i];

			x = a[i];

		}

		else if(a[i] - a[i - 1] > T) x = x + T;

		else x = x + a[i] - a[i - 1];

	}

	printf("%lld\n", x + T);

	return 0;

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

#include<cmath>

#include<cstring>

#include<iostream>

#include<cstdlib>

#include<algorithm>

#include<map>

using namespace std;



int n, t;

int a[200005];

int main()

{

	scanf("%d%d", &n, &t);

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

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

	long long sum = 0;

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

	{

		int ant = a[i] - a[i-1];

		if(ant < t) sum += ant;

		else sum += t;

	}

	printf("%lld\n", sum + t);

}


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

using namespace std;

const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

	for(int i = 1; i <= N; i++)	scanf("%lld", &a[i]);

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

	{

		if(a[i] <= T)

		{

			flag = a[i];

			x = a[i];

		}

		else if(a[i] - a[i - 1] > T) x = x + T;

		else x = x + a[i] - a[i - 1];

	}

	printf("%lld\n", x + T);

	return 0;

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

using namespace std;

int n,t,a[200005],l,r,j;

long long s;

int main()

{

	cin>>n>>t;

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

	{

		cin>>a[i];

	}



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

	{

	  if(i==n)s+=t;

	  else if(a[i+1]-a[i]<=t)s=s+a[i+1]-a[i];

	  else if(a[i+1]-a[i]>t)s+=t;

	}

	cout<<s;

	return 0;

}

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

using namespace std;

const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

	for(int i = 1; i <= N; i++)	scanf("%lld", &a[i]);

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

	{

		if(a[i] <= T)

		{

			flag = a[i];

			x = a[i];

		}

		else if(a[i] - a[i - 1] > T) x = x + T;

		else x = x + a[i] - a[i - 1];

	}

	printf("%lld\n", x + T);

	return 0;

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

int main()

{

	int a[200005];

	int b[200005];

	int n, i, t;

	scanf("%d %d", &n, &t);

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

	{

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

		b[i] = a[i] + t;

	}

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

	{

		if(b[i] > a[i + 1])

		{

			a[i + 1] = b[i];

		}

	}

	int sum = 0;

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

	{

		sum = sum + b[i] - a[i];

	}

	printf("%d\n",sum);

	return 0;

}


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

using namespace std;

const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

	for(int i = 1; i <= N; i++)	scanf("%lld", &a[i]);

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

	{

		if(a[i] <= T)

		{

			flag = a[i];

			x = a[i];

		}

		else if(a[i] - a[i - 1] > T) x = x + T;

		else x = x + a[i] - a[i - 1];

	}

	printf("%lld\n", x + T);

	return 0;

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

    #include<cstring>

    #include<cstdio>

    #include<cstdlib>

    #include<algorithm>

    #include<map>

    #include<cmath>

    #include<cstdlib>

    using namespace std;

    const int M=200005;

long long int n,m,flag,sum;

int a[M];

int main()

{

   cin>>n>>m;

   cin>>a[1];

   sum=0;

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

   {

        cin>>a[i];

        if(a[i]-a[i-1]>=m)

            sum+=m;

        else if(a[i]-a[i-1]<m)

            sum+=a[i]-a[i-1];

   }

   sum+=m;

   cout<<sum<<endl;

}


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

using namespace std;

const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

	for(int i = 1; i <= N; i++)	scanf("%lld", &a[i]);

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

	{

		if(a[i] <= T)

		{

			flag = a[i];

			x = a[i];

		}

		else if(a[i] - a[i - 1] > T) x = x + T;

		else x = x + a[i] - a[i - 1];

	}

	printf("%lld\n", x + T);

	return 0;

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

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<map>

#include<iostream>

#include<algorithm>

using namespace std; 

int n,t;

int a[200005];



int main()

{

	cin>>n>>t;

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

	{

		cin>>a[i];

	}

	int ans=t;

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

	{

		int temp;

		temp=a[i]-a[i-1];

		if(temp>=t)

		   ans+=t;

		else

		   ans+=temp;

	}

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;

const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

	for(int i = 1; i <= N; i++)	scanf("%lld", &a[i]);

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

	{

		if(a[i] <= T)

		{

			flag = a[i];

			x = a[i];

		}

		else if(a[i] - a[i - 1] > T) x = x + T;

		else x = x + a[i] - a[i - 1];

	}

	printf("%lld\n", x + T);

	return 0;

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

#include<cstdlib>

#include<cstring>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

	long long int i,N,T,X = 0,t[200005];

	scanf("%lld %lld\n",&N,&T);

	for(i = 0;i < N; i++)

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

	if(N > 1)

	{

		for(i = 0;i < N - 1; i++)

		{

			if(t[i + 1] - t[i] >= T)

				X += T;

			else

				X += t[i + 1] - t[i];

		}

	}

		X += T;

		printf("%lld\n",X);

	return 0;

}

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

using namespace std;

const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

	for(int i = 1; i <= N; i++)	scanf("%lld", &a[i]);

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

	{

		if(a[i] <= T)

		{

			flag = a[i];

			x = a[i];

		}

		else if(a[i] - a[i - 1] > T) x = x + T;

		else x = x + a[i] - a[i - 1];

	}

	printf("%lld\n", x + T);

	return 0;

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



typedef long long ll;



using namespace std;



int main() {

    ll n, t, prev;

    cin >> n >> t >> prev;

    ll now, cnt = t;

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

        cin >> now;

        if (now < prev + t) cnt += (now - prev);

        else cnt += t;

        prev = now;

    }

    cout << cnt << endl;

    return 0;

}


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



typedef long long ll;



using namespace std;



int main() {

    ll n, t, prev;

    scanf("%lld%lld%lld", &n, &t, &prev);

    ll now, cnt = t;

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

        scanf("%lld", &now);

        if (now < prev + t) cnt += (now - prev);

        else cnt += t;

        prev = now;

    }

    printf("%lld\n", cnt);

    return 0;

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

#include<cstdlib>

#include<cstring>

#include<string>

#include<queue>

#include<algorithm>

#include<iostream>

#include<cmath>

#include<map>

#include<set>

using namespace std;

int main()

{

	int N,T,A,B;

	while( scanf(" %d %d",&N,&T) != EOF ){

		scanf(" %d",&A);

		int sum = 0;

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

			scanf(" %d",&B);

			if( B - A > T )

				sum += T;

			else

				sum += (B - A);

			A = B;

		}

		sum += T;

		printf("%d\n",sum);

	}

}

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

const int maxn = 2e6 + 5;

long long a[maxn];

int main(){

	int n ;

	long long m ;

	scanf("%d%lld",&n,&m);

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

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

		}

	long long sum = m;

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

		if(a[i] - a[i - 1] >= m)sum += m;

		else sum += a[i] - a[i - 1];

		}

	printf("%lld\n",sum);

	return 0;

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

#include <vector>

using namespace std;



typedef long long ll;



const int N  = 200030;

ll t[N];



int main()

{

    int n,T;

    cin >> n >> T;

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

    {

        cin >> t[i];

    }



    ll sum = 0;

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

    {

        if(t[i] - t[i-1] >= T) sum += T;

        else sum += (t[i]-t[i-1]);

    }

    cout << sum+T << endl;

    return 0;

}

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

const int maxn = 2e6 + 5;

long long a[maxn];

int main(){

	int n ;

	long long m ;

	scanf("%d%lld",&n,&m);

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

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

		}

	long long sum = m;

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

		if(a[i] - a[i - 1] >= m)sum += m;

		else sum += a[i] - a[i - 1];

		}

	printf("%lld\n",sum);

	return 0;

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

#include<cmath>

#include<cstring>

#include<iostream>

#include<cstdlib>

#include<algorithm>

#include<map>

using namespace std;



int n, t;

int a[200005];

int main()

{

	scanf("%d%d", &n, &t);

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

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

	long long sum = 0;

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

	{

		int ant = a[i] - a[i-1];

		if(ant < t) sum += ant;

		else sum += t;

	}

	printf("%lld\n", sum + t);

}


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

#include<cstring>

#include<cmath>

#include<string>

#include<cstdlib>

#include<algorithm>

using namespace std;



const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

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

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

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

		{

			if(a[i] <= T)

			{

				flag = a[i];

				x = a[i];

			}

			else if(a[i] - a[i - 1] > T)

				x += T;

			else

				x += a[i] - a[i - 1];

		}

		printf("%lld\n", x + T);

		return 0;

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

#include<algorithm>

#include<cstring>

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

	int a[200005];

	long long sum = 0, n, i, t;

	scanf("%lld%lld",&n,&t);

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

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

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

	{

		if(i == 0&&n == 1)

		{

			sum = sum + t;

			continue;

		}

		if(i > 0)

		{

		    if((a[i]-a[i-1])>=t)

		    	sum += t;

     		else

	     		sum += (a[i]-a[i-1]);

	    }

	}

	if(i != 1)

	sum = sum + t;

	printf("%lld\n",sum);

}

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

#include<cstring>

#include<cmath>

#include<string>

#include<cstdlib>

#include<algorithm>

using namespace std;



const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

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

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

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

		{

			if(a[i] <= T)

			{

				flag = a[i];

				x = a[i];

			}

			else if(a[i] - a[i - 1] > T)

				x += T;

			else

				x += a[i] - a[i - 1];

		}

		printf("%lld\n", x + T);

		return 0;

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

typedef long long LL;



using namespace std;

int main(){

	int N,T,t;

	while(cin>>N>>T){

		LL ans = T,x=0;

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

			cin>>t;

			if(t-x<T)

				ans+=t-x;

			else ans+=T;

			x = t;

		}	

		cout<<ans<<endl;

	}



	return 0;

}

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

#include<cstring>

#include<cmath>

#include<string>

#include<cstdlib>

#include<algorithm>

using namespace std;



const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

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

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

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

		{

			if(a[i] <= T)

			{

				flag = a[i];

				x = a[i];

			}

			else if(a[i] - a[i - 1] > T)

				x += T;

			else

				x += a[i] - a[i - 1];

		}

		printf("%lld\n", x + T);

		return 0;

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

#include<cstring>

#include<iostream>

#include<map>

#include<queue>

using namespace std;



int main(){

	int a[200005];

	int n,t,i,T=0;

	scanf("%d%d",&n,&t);

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

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

	}

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

		if((a[i]-a[i-1])>=t) T=T+t;

		if((a[i]-a[i-1])<t) T=T+(a[i]-a[i-1]);   	   

	}

	T=T+t;

	printf("%d\n",T);

}


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

#include<cstring>

#include<cmath>

#include<string>

#include<cstdlib>

#include<algorithm>

using namespace std;



const int MaxN = 2e5;

long long a[MaxN + 5];

int N;

long long T, x;



int main()

{

	long long flag = 0;

	scanf("%d %lld", &N, &T);

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

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

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

		{

			if(a[i] <= T)

			{

				flag = a[i];

				x = a[i];

			}

			else if(a[i] - a[i - 1] > T)

				x += T;

			else

				x += a[i] - a[i - 1];

		}

		printf("%lld\n", x + T);

		return 0;

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



int ri() {

	int n;

	scanf("%d", &n);

	return n;

}



int main() {

	int n = ri();

	int cnt[n + 1];

	memset(cnt, 0, sizeof(cnt));

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

		for (int j = i; j <= n; j += i) cnt[j]++;

	}

	int64_t res = 0;

	for (int i = 0; i <= n; i++) res += (int64_t) i * cnt[i];

	printf("%" PRId64 "\n", res);

	return 0;

}


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



int ri() {

	int n;

	scanf("%d", &n);

	return n;

}

// O(sqrt(N))



int main() {

	int n = ri();

	int m = sqrt(n);

	auto calc = [&] (int n) { // sum [1, n]

		return (int64_t) n * (n + 1) / 2;

	};

	int64_t res = 0;

	for (int i = 1; i <= m; i++) res += i * calc(n / i);

	for (int i = 1; i <= m; i++) res += (calc(n / i) - calc(std::max(m, n / (i + 1)))) * calc(i);

	printf("%" PRId64 "\n", res);

	return 0;

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

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

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

#define debug(x) cerr<<#x<<": "<<(x)<<endl

#define INF      (int)1e9

#define EPS      (double)1e-9

#define MOD      ((int)1e9+7)

using namespace std;

typedef long long     llong;

typedef vector<int>   vi;

typedef vector<vi >   vvi;

typedef vector<vvi >  vvvi;

typedef pair<int,int> pii;

template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}



int main(){

	int n;

	cin>>n;

	

	vi dp(n+1,1);

	bool jud[n+1]={};

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

		if(jud[i]){}

		else{

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

				int cnt=0;

				int tmp=j;

				while(tmp%i==0){

					tmp/=i;

					cnt++;

				}

				dp[j]*=cnt+1;

				jud[j]=true;

			}

		}

	}

	

	llong ans=0;

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

		ans+=i*dp[i];

	}

	

	cout<<ans<<endl;

}


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

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

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

#define debug(x) cerr<<#x<<": "<<(x)<<endl

#define INF      (int)1e9

#define EPS      (double)1e-9

#define MOD      ((int)1e9+7)

using namespace std;

typedef long long     llong;

typedef vector<int>   vi;

typedef vector<vi >   vvi;

typedef vector<vvi >  vvvi;

typedef pair<int,int> pii;

template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}



//解説参考.

int main(){

	int n;

	cin>>n;

	

	llong ans=0;

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

		llong tmp=n/i;

		ans+=i*tmp*(tmp+1)/2;

	}

	

	cout<<ans<<endl;

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

#include <vector>

#include <string>

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;

using ll = long long;



struct Sieve {

    Sieve(int n) : l(n + 1, 0) {

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

            if (!l[i]) p.push_back(l[i] = i);

            for (int q : p) {

                if (q > l[i]) break;

                if (int j = i * q; j <= n) l[j] = q; else break;

            }

        }

    }

    bool is_prime(int i) {

        return l[i] == i;

    }

    vector<int> l, p;

};



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);



    int n;

    cin >> n;



    Sieve si(n);

    ll r = 0;



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

        int t = i, d = 1;

        while (t > 1) {

            int k = 1;

            int l = si.l[t];

            while (t % l == 0) t /= l, k++;

            d *= k;

        }

        r += (ll)i * d;

    }



    cout << r << endl;



    return 0;

}

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

#include <vector>

#include <string>

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;

using ll = long long;



int main() {

    int n;

    cin >> n;



    ll r = 0;

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

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

            r += j;

        }

    }



    cout << r << endl;



    return 0;

}