#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>

using namespace std;

const int maxn=2e5;
int n,t,pos;
int a[maxn+5];

int main(){
	scanf("%d %d",&n,&t);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		}
		if(n==1)
			pos = t;
			else if(n>1){
				if(a[n]-a[n-1]<t){
					pos = a[n] + t;
				}
				else if(a[n]-a[n-1]>=t){
						for(int i=2;i<=n;i++){
							if(a[i]-a[i-1]>=t){
								pos = a[i-1] + t*(n-i+1);
								}
							}
		        }	
		}
		printf("%d",pos);
}
