[POI2014] ZAL-Freight

题意翻译

Upper Bytown和Lower Bytown的火车站通过一条轨道铁路连接。 沿任何一个方向在它们之间行驶都需要s分钟。 但是,离开车站的火车必须至少间隔一分钟。 而且,在任何时候,铁路上的所有列车都必须朝同一方向行驶。 根据我们的时间表,前往下拜镇的n列货运列车将通过上拜镇。 他们将在下拜敦装载货物,然后返回上拜敦。 为简单起见,我们假设将货物装载到火车上几乎不需要时间。 我们将确定最后一班火车返回Upper Bytown的最短时间。 **两个车站发车都必须至少间隔一分钟。**

题目描述

The train stations in Upper Bytown and Lower Bytown are connected with a single track rail link. It takes the train $s$ minutes to travel between them in either direction. However, the trains departing a station have to be spaced at least one minute apart. Moreover, at all times, all the trains on the rail link have to go in the same direction. According to the timetable at our disposal, $n$ cargo trains destined for Lower Bytown are to pass through the Upper Bytown. They are to be loaded with goods in Lower Bytown and then return to Upper Bytown. For simplicity, we assume that loading the goods on the train takes virtually no time. We are to determine the minimum possible time of the last train returning to Upper Bytown. 有两个城镇,从A到B需要的时间为S,然后有N辆列车需要从A到B再回来,任何时刻铁路上只能有向着同一个方向前进的列车,然后每辆列车有一个从A出发的最早出站时间,问所有列车全部回到A站的最早时间

输入输出格式

输入格式


The first line of the standard input contains two integers $n$, $s$($1\le n\le 1\ 000\ 000$, $1\le s\le 10^9$), separated by a single space, that specify the number of trains and the one-way travel time respectively. The second line contains $n$ integers $t_1,t_2,\cdots,t_n$ ($0\le t_1\le t_2\le\cdots\le t_n\le 10^9$),separated by a single space, that specify the arrival times of successive trains at the Upper Bytown station.

输出格式


Your program should print out a single line with a single integer to the standard output: the minimum possible time of the last train returning to Upper Bytown.

输入输出样例

输入样例 #1

3 4
1 8 11

输出样例 #1

20

说明