The train stations of Upper Bytown and Lower Bytown are joined by a single track. A train needs s minutes to travel between them, in either direction. Trains leaving the same station must depart at least one minute apart. At every moment, all trains on the track have to move in the same direction. A train may depart from a station at the exact minute another train arrives there.
According to the timetable, n freight trains bound for Lower Bytown pass through Upper Bytown. Train i reaches Upper Bytown at minute ti and cannot depart before that. Each train runs to Lower Bytown, takes on goods there, and returns to Upper Bytown. Loading the goods takes no time.
Find the earliest minute at which the last train can be back in Upper Bytown.
The first line contains two integers n and s separated by a single space, the number of trains and the one-way travel time (1≤n≤106, 1≤s≤109). The second line contains n integers t1,t2,…,tn separated by single spaces, the arrival times of the trains at the Upper Bytown station (0≤t1≤t2≤⋯≤tn≤109).
Print one line with a single integer: the earliest minute at which the last train is back in Upper Bytown.
In the first example the minimum is reached when the trains leave Upper Bytown at minutes 1, 9 and 11, and leave Lower Bytown at minutes 5, 15 and 16.