Finally! Vasya have come of age and that means he can finally get a passport! To do it, he needs to visit the passport office, but it's not that simple. There's only one receptionist at the passport office and people can queue up long before it actually opens. Vasya wants to visit the passport office tomorrow.

He knows that the receptionist starts working after ts minutes have passed after midnight and closes after tf minutes have passed after midnight (so that (tf - 1) is the last minute when the receptionist is still working). The receptionist spends exactly t minutes on each person in the queue. If the receptionist would stop working within t minutes, he stops serving visitors (other than the one he already serves). 

Vasya also knows that exactly n visitors would come tomorrow. For each visitor Vasya knows the point of time when he would come to the passport office. Each visitor queues up and doesn't leave until he was served. If the receptionist is free when a visitor comes (in particular, if the previous visitor was just served and the queue is empty), the receptionist begins to serve the newcomer immediately.

<image> "Reception 1"

For each visitor, the point of time when he would come to the passport office is positive. Vasya can come to the office at the time zero (that is, at midnight) if he needs so, but he can come to the office only at integer points of time. If Vasya arrives at the passport office at the same time with several other visitors, he yields to them and stand in the queue after the last of them.

Vasya wants to come at such point of time that he will be served by the receptionist, and he would spend the minimum possible time in the queue. Help him!

Input

The first line contains three integers: the point of time when the receptionist begins to work ts, the point of time when the receptionist stops working tf and the time the receptionist spends on each visitor t. The second line contains one integer n — the amount of visitors (0 ≤ n ≤ 100 000). The third line contains positive integers in non-decreasing order — the points of time when the visitors arrive to the passport office.

All times are set in minutes and do not exceed 1012; it is guaranteed that ts < tf. It is also guaranteed that Vasya can arrive at the passport office at such a point of time that he would be served by the receptionist.

Output

Print single non-negative integer — the point of time when Vasya should arrive at the passport office. If Vasya arrives at the passport office at the same time with several other visitors, he yields to them and queues up the last. If there are many answers, you can print any of them.

Examples

Input

10 15 2
2
10 13


Output

12

Input

8 17 3
4
3 4 5 8


Output

2

Note

In the first example the first visitor comes exactly at the point of time when the receptionist begins to work, and he is served for two minutes. At 12 minutes after the midnight the receptionist stops serving the first visitor, and if Vasya arrives at this moment, he will be served immediately, because the next visitor would only come at 13 minutes after midnight.

In the second example, Vasya has to come before anyone else to be served. 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Codeforces {

    private static final Scanner sc = new Scanner(System.in);
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final long MOD = (long) (1e9 + 7);

    public static int[] LPS(String p){
        int[] lps = new int[p.length()];

        int i=1;
        int j=0;
        while (i < p.length()){
            if (p.charAt(i) == p.charAt(j)){
                lps[i] = j+1;
                i++;
                j++;
            }
            else{
                if (j == 0){
                    lps[i] = 0;
                    i++;
                }
                else{
                    j = lps[j-1];
                }
            }
        }
        return lps;
    }

    public static void KMP(String text,String pattern){
        int[] lps = LPS(pattern);
        int i = 0;
        int j = 0;
        ArrayList<Integer> matches = new ArrayList<>();
        while (i < text.length()){
            if (text.charAt(i) == pattern.charAt(j)){
                i++;
                j++;
            }
            else{
                if (j != 0){
                    j = lps[j-1];
                }
                else {
                    i++;
                }
            }
            if (j == pattern.length()) {
                matches.add(i - j);
                j = lps[j-1];
            }
        }
        for (int x : matches){
            System.out.println("Match at : " + x);
        }
    }

    private static class SegmentTree{
        private long[] st;
        private int size;
        private int n;
        private long[] a;
        SegmentTree(long[] a,int n){
            this.size = 4*n;
            this.n = n;
            this.a = a;
            st = new long[size];
            //Arrays.fill(st,Integer.MIN_VALUE);
            buildSegmentTree(0,0,n-1);
            //printSegmentTree();
        }
        public long buildSegmentTree(int index,int l,int r){
            if (l == r){
                st[index] = a[l];
                return a[l];
            }
            int mid = (r+l) >> 1;
            return st[index] = buildSegmentTree(2*index+1,l,mid) + buildSegmentTree(2*index+2,mid+1,r);
        }
        public void printSegmentTree(){
            for (long x : st){
                System.out.print(x + " ");
            }
            System.out.println();
        }
        public long query(int ql,int qr){
            return getQuery(0,0,n-1,ql-1,qr-1);
        }
        private long getQuery(int index,int sl,int sr,int ql,int qr){
            //System.out.println("#" + index);
            if (qr < sl || ql > sr)
                return 0;
            if (ql <= sl && qr >= sr)
                return st[index];
            int mid = (sr + sl) >> 1;
            return getQuery(2*index+1,sl,mid,ql,qr) + getQuery(2*index+2,mid+1,sr,ql,qr);
        }
        public void update(int i,long newVal){
            //long diff = newVal - a[i];
            a[i] = newVal;
            updateSegmentTree(0,i,0,n-1,newVal);
        }
        private void updateSegmentTree(int index,int i,int sl,int sr,long diff){
            if (sl == sr){
                st[index] = diff;
                return;
            }
            int mid = (sl + sr) >> 1;
            if (i <= mid)
                updateSegmentTree(2*index+1,i,sl,mid,diff);
            else
                updateSegmentTree(2*index+2,i,mid+1,sr,diff);
            st[index] = st[2*index+1] + st[2*index+2];
        }
    }

    public static class Pair<T1,T2>{
        T1 first;
        T2 second;
        Pair(T1 a,T2 b){
            this.first = a;
            this.second = b;
        }

        @Override
        public String toString() {
            return "[" + first + ", " + second + "]";
        }
    }

    public static long GCD(long a,long b){
        if (b == 0)
            return a;
        return GCD(b,a%b);
    }

    static int highestPowerOf2(int n) {
        int p = (int)(Math.log(n) /
                Math.log(2));
        return (int)Math.pow(2, p);
    }

    public static int binSearch(long[] a,long x){
        int l = 0;
        int r = a.length - 1;
        while (l <= r){
            int mid = l + (r-l)/2;
            if (a[mid]==x)
                return 1;
            else if (a[mid] < x)
                l = mid+1;
            else
                r = mid-1;
        }
        return -1;
    }

    public static int upperBound(long[] arr,long key){
        int start=0;int end=arr.length-1;
        int idx=-1;
        int mid;
        while(start<=end){
            int i=(start+end)/2;
            if(arr[i]<key){
                start=i+1;
            }
            else if(arr[i]>key){
                end=i-1;
            }
            else{
                idx=i;
                start=i+1;
            }
        }

        return idx;    }

    public static int lowerBound(long[] arr,long key){
        int start=0;int end=arr.length-1;
        int idx=-1;
        int mid;
        while(start<=end){
            int i=(start+end)/2;
            if(arr[i]<key){
                start=i+1;
            }
            else if(arr[i]>key){
                end=i-1;
            }
            else{
                idx=i;
                end=i-1;
            }
        }
        return idx;
    }

    public static int searchInsert(long[] nums, long target) {
        int s=0,e=nums.length-1;
        int mid;
        if(target<nums[0]){
            return 0;
        }
        while(s<=e){
            mid=(s+e)/2;
            if(nums[mid]>target){
                e=mid-1;
            }
            else if(nums[mid]==target){
                return mid;
            }
            else{
                s=mid+1;
            }
        }
        return s;
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (long i = 5; i <= Math.sqrt(n); i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }

    public static long fastExpo(long a,int n,int mod){
        if (n == 0)
            return 1;
        else{
            if ((n&1) == 1){
                long x = fastExpo(a,n/2,mod);
                return (((a*x)%mod)*x)%mod;
            }
            else{
                long x = fastExpo(a,n/2,mod);
                return (((x%mod)*(x%mod))%mod)%mod;
            }
        }
    }

    public static long modInverse(long n,int p){
        return fastExpo(n,p-2,p);
    }

    public static long nCr(int n,int r,long[] fact,int mod){
        long val =  (((fact[n] * modInverse(fact[r],mod))%mod)*modInverse(fact[n-r],mod))%mod;
        return val;
    }

    public static void factorial(long[] fact,int n,int mod){
        for (int i=1;i<=n;i++){
            fact[i] = (fact[i-1] * i)%mod;
        }
    }

    public static int log2(long val){
        return (int) Math.floor(Math.log(val)/Math.log(2));
    }

    public static boolean isSubSequence(String s,String t){
        int i = 0;
        int j = 0;
        while (i < s.length() && j < t.length()){
            if (s.charAt(i) == t.charAt(j))
                j++;
            i++;
        }
        return j == t.length();
    }

    public static boolean isTriangle(long x,long y,long z){
        if (x == 0 || y == 0 || z == 0)
            return false;
        if (x + y > z && y + z > x  && x + z > y)
            return true;
        return false;
    }

    public static void solve() throws IOException {
        long ts = sc.nextLong();
        long tf = sc.nextLong();
        long t = sc.nextLong();
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        long ans = ts;
        long s = ts;
        long min =Long.MAX_VALUE;
        //System.out.println(min);
        for (int i = 0; i < n; i++) {
            if (s + t > tf)
                break;
            if (a[i] <= s){
                if (min > s - a[i] + 1){
                    min = s - a[i] + 1;
                    ans = a[i]-1;
                }
                s += t;
            }
            else{
                System.out.println(s);
                return;
            }
        }
        if (s + t <= tf) ans = s;
        System.out.println(ans);
    }
    public static void main(String[] args) throws IOException {
        int t;
//        t = sc.nextInt();
        t = 1;
        while (t-- > 0){
            solve();
        }
        System.gc();
    }
}
	 		  	 		 			 	 				 	  		  		