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.BufferedWriter;
	import java.io.IOException;
	import java.io.OutputStreamWriter;
	import java.io.ObjectInputStream.GetField;
	import java.math.BigInteger;
	import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.Collections;
	import java.util.HashMap;
	import java.util.HashSet;
	import java.util.InputMismatchException;
	import java.util.LinkedList;
	import java.util.List;
	import java.util.Map;
	import java.util.PriorityQueue;
	import java.util.Queue;
	import java.util.Stack;
	import java.util.TreeMap;
	import java.util.TreeSet;
	public class Q2 {
		
		static long MOD = 1000000007;
		static boolean b1,b[],bc[];
		static boolean boo[][][];
		static int ans1 = -1,ans2 = -1, root;
		static ArrayList<Integer>[] amp,amp1;
		static int sum[],dist[],cnt[];
		static long ans = 0;
		static long p = 0;
		//static ArrayList<Pair3>[][][] pmp;
		static FasterScanner sc = new FasterScanner();
		static Queue<Integer> q = new LinkedList<>();
		static int arr[],start[],end[],color[];
		static PriorityQueue<Integer> pq;
		//static ArrayList<Integer> parent = new ArrayList<>();
		static LinkedList<Integer> fa;
		static BufferedWriter log;
		static TreeMap<Integer,Integer> tm = new TreeMap<>();
		static HashSet<Integer> hs = new HashSet<>();
		static Stack<Integer> stack = new Stack<>();
		static Pair prr[];
		static long parent1[],parent2[],size[][],size1[],size2[],value[];
		public static void main(String[] args) throws Exception {
	    	new Thread(null, new Runnable() {
				public void run() {
					try {
						soln();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}, "1", 1 << 27).start();
	    }
		public static void soln() throws IOException {
			log = new BufferedWriter(new OutputStreamWriter(System.out));
			long t1 = sc.nextLong(), t2 = sc.nextLong(), k = sc.nextLong();
			int n = sc.nextInt();
			long arr[] = sc.nextLongArray(n);
			HashMap<Long,Integer> hm = new HashMap<>();
			for(long l : arr){
				if(hm.containsKey(l)){
					hm.put(l, hm.get(l)+1);
				}
				else hm.put(l, 1);
			}
			long ans = t1, temp = 0;
			for(int i = 0; i< n; i++){
				if(i>0 && arr[i]==arr[i-1]) continue;
				if(t2<arr[i]){
					System.out.println(t1);
					return;
				}
				if((t1-(arr[i]-1))<ans){
					ans = Math.max(0, t1-(arr[i]-1));
					temp = arr[i]-1;
				}
				t1=Math.max(t1,arr[i])+(hm.get(arr[i])*k);
				if(t1>t2) break;
			}
		//	System.out.println(t1);
			if((t1+k)<=(t2)) System.out.println(t2-k);
			else System.out.println(temp);
			log.close();
		}
		public static int dfs(int x) throws IOException{
			if(b1) return 0;
			int ans = arr[x];
			b[x] = true;
			for(int e:amp[x]){
				if(b1) return 0;
				if(!b[e]){
					ans+=dfs(e);
				}
			}
		//	System.out.println(value[x]+" "+p);
			if(x!=root && ans==p){
				if(ans1==-1){
					ans1 = x+1;
					ans = 0;
				}
				else if(ans2==-1){
					ans2 = x+1;
					ans = 0;
					System.out.println(ans1+" "+ans2);
					System.exit(0);
				}
			}
			if(b1) return 0;
			return ans;
		}
		static boolean check(long arr1[] , long arr2[] , int key ,int x){
			for(int i =0 ; i< key && i<arr1.length ;i++){
				long sum = 0;
				if((key-(i+1))<=arr2.length){
					if((key-(i+1))!=0)
					sum += (arr1[i]+arr2[key-(i+1)-1]);
					else sum = arr1[i];
					if(sum<=x) return true;
				}
			}
			if(key>0 && key<=arr2.length && arr2[key-1]<=x) return true;
			return false;
		}
		public static int binarySearch(long arr[],long key){
			int low = 0, high = arr.length-1;
			while(low<high){
				int mid = (high+low+1)/2;
				if(arr[mid] >= key) low = mid;
				else high = mid-1;
			}
			if(arr[low]<key)
			return low+1;
			else return 0;
		}
		public static void bfs(int x,int arr[]){
		b = new boolean[arr.length];
		b[x] = true;
		q = new LinkedList<>();
		q.add(x);
		while(!q.isEmpty()){
			int y = q.poll();
			for(int i = 0;i<amp[y].size();i++) {
				if(!b[amp[y].get(i)]){
					q.add(amp[y].get(i));
					b[amp[y].get(i)] = true;
					arr[amp[y].get(i)] = (arr[y]+1);
				}
			}
		}
		}
		
		static long get(long x){
			if((x%10)<5) return x-(x%10);
			else return x+(10-x%10);
		}
		
		static long func(long n, long d, long t){
			return (t*(2*(n-1)+(t-1)*(d)))/2;
		}
		static class Pair implements Comparable<Pair> {
			int u;
			int v;
			public Pair(int u, int v) {
				this.u = u;
				this.v = v;
			}
			
			public int hashCode() {
				int hu = (int) (u ^ (u >>> 32));
				int hv = (int) (v ^ (v >>> 32));
				return 31*hu + hv;
			}
	 
			public boolean equals(Object o) {
				Pair other = (Pair) o;
				return (u == other.u && v == other.v);
			}
	 
			public int compareTo(Pair other) {
				return Integer.compare(u, other.u) != 0 ? (Integer.compare(u, other.u)) : (Integer.compare(v, other.v));
			}
			
			public String toString() {
				return "[u=" + u + ", v=" + v + "]";
			}
		}
		public static void buildGraph(int n){
			for(int i =0;i<n;i++){
				int x = sc.nextInt(), y = sc.nextInt();
				amp[--x].add(--y);
				amp[y].add(x);
			}
		}
		
		
		public static long getParent(long x, long parent[]){
			while(parent[(int) x]!=x){
				parent[(int) x] = parent[(int) parent[(int) x]];
				x = parent[(int) x];
			}
			return x;
		}
		static long min(long a, long b, long c){
			if(a<b && a<c) return a;
			if(b<c) return b;
			return c;
		}
		/*
		static void dfs3D(int x,int y,int z){
			ans++;
			boo[x][y][z] = true;
			for(Pair3 e:pmp[x][y][z]){
				if(!boo[e.x][e.y][e.z]){
					dfs3D(e.x,e.y,e.z);
				}
			}
		}
		static class Pair3{
			int x, y ,z;
			Pair3(int x, int y, int z){
				this.x = x;
				this.y = y;
				this.z = z;
			}
		}*/
		static int sum(int n){
			String str = Integer.toString(n);
			int cnt = 0;
			for(int i = 0; i< str.length();i++){
				cnt+=(str.charAt(i)-'0');
			}
			return cnt;
		}
		 static void KMPSearch(String pat, String txt)
		    {
		        int M = pat.length();
		        int N = txt.length();
		 
		        // create lps[] that will hold the longest
		        // prefix suffix values for pattern
		        int lps[] = new int[M];
		        int j = 0;  // index for pat[]
		 
		        // Preprocess the pattern (calculate lps[]
		        // array)
		        computeLPSArray(pat,M,lps);
		 
		        int i = 0;  // index for txt[]
		        while (i < N)
		        {
		            if (pat.charAt(j) == txt.charAt(i))
		            {
		                j++;
		                i++;
		            }
		            if (j == M)
		            {
		               // parent.add((i-j));
		                j = lps[j-1];
		            }
		 
		            // mismatch after j matches
		            else if (i < N && pat.charAt(j) != txt.charAt(i))
		            {
		                // Do not match lps[0..lps[j-1]] characters,
		                // they will match anyway
		                if (j != 0)
		                    j = lps[j-1];
		                else
		                    i = i+1;
		            }
		        }
		    }
		 static void computeLPSArray(String pat, int M, int lps[])
		    {
		        // length of the previous longest prefix suffix
		        int len = 0;
		        int i = 1;
		        lps[0] = 0;  // lps[0] is always 0
		 
		        // the loop calculates lps[i] for i = 1 to M-1
		        while (i < M)
		        {
		            if (pat.charAt(i) == pat.charAt(len))
		            {
		                len++;
		                lps[i] = len;
		                i++;
		            }
		            else  // (pat[i] != pat[len])
		            {
		                // This is tricky. Consider the example.
		                // AAACAAAA and i = 7. The idea is similar 
		                // to search step.
		                if (len != 0)
		                {
		                    len = lps[len-1];
		 
		                    // Also, note that we do not increment
		                    // i here
		                }
		                else  // if (len == 0)
		                {
		                    lps[i] = len;
		                    i++;
		                }
		            }
		        }
		    }
		private static void permutation(String prefix, String str) {
		    int n = str.length();
		    if (n == 0); //hs.add(prefix);
		    else {
		        for (int i = 0; i < n; i++)
		            permutation(prefix + str.charAt(i), str.substring(0, i) + str.substring(i+1, n));
		    }
		}
		public static char give(char c1,char c2){
			if(c1!='a' && c2!='a') return 'a';
			if(c1!='b' && c2!='b') return 'b';
			return 'c';
		}
		static class Graph{
			int vertex;
			long weight;
		}
		public static void buildTree(int n){
			int arr[] = sc.nextIntArray(n);
			for(int i = 0;i<n;i++){
				int x = arr[i]-1;
				amp[i+1].add(x);
				amp[x].add(i+1);
			}
		}
		
		
		static class SegmentTree{
			int pre[], suf[], max[], val[];
			SegmentTree( int n){
				int size = 4*n;
				pre = new int[size];
				suf = new int[size];
				max = new int[size];
				val = new int[size];
				build(0,n-1,1);
			}
			void build(int ss, int se, int si){
				if(ss==se){
					pre[si] = 1;
					suf[si] = 1;
					max[si] = 1;
					val[si] = arr[ss];
				}
				else{
				int mid = (ss+se)>>2;
				si*=2;
				build(ss,mid,si);build(mid+1,se,si+1);
				}
			}
			
			/*int[] get(int qs, int qe, int ss, int se, int si){
				if(qe < ss || se < qs)
	        		return new int[2];
				if(qs<=ss && qe>=se){
					return new int[]{max[si],val[si]};
				}
				int mid = (ss+se)/2;
				si*=2;
				if(qe<=mid) return get(qs,qe,ss,mid,si);
				else if(qs>mid) return get(qs,qe,mid+1,se,si+1);
				long a1[] = build(ss,mid,si*2), a2[] = build(mid+1,se,si*2+1);
				long ans[] = new long[4];
				if(arr[mid] == arr[mid+1]){
				    long temp = a1[2]+a2[0];
				    if(temp>=a2[1] && temp>=a1[1]){
				        ans[1] = temp;
				        ans[3] = arr[mid];
				    }
				    else if(a2[1]>=a1[1]){
				        ans[1] = a2[1];
				        ans[3] = a2[3];
				    }
				    else{
				        ans[1] = a1[1];
				        ans[3] = a1[3];
				    } 
				    if(a1[1]==(mid-ss+1)) ans[0] = ans[1];
				    else ans[0] = a1[0];
				    if(a2[2]==(se-mid)) ans[2] = ans[1];
					else ans[2] = a2[2];
				}
				else{
					if(a2[1]>=a1[1]){
				        ans[1] = a2[1];
				        ans[3] = a2[3];
				    }
				    else{
				        ans[1] = a1[1];
				        ans[3] = a1[3];
				    } 
					ans[0] = a1[0];
					ans[2] = a2[2];
				}
	            return ans;
			}
			void print(){
				for(int i = 0;i<st.length;i++){
					System.out.println(st[i][0]+" "+st[i][1]+" "+st[i][2]+" "+st[i][3]);
				}
				System.out.println();
			}*/
		}
		static int convert(int x){
			int cnt = 0;
			String str = Integer.toBinaryString(x);
			//System.out.println(str);
			for(int i = 0;i<str.length();i++){
				if(str.charAt(i)=='1'){
					cnt++;
				}
			}
			int ans = (int) Math.pow(3, 6-cnt);
			return ans;
		}
		static class Node2{
			Node2 left = null;
			Node2 right = null;
			Node2 parent = null;
			int data;
		}
		static class BinarySearchTree{
			Node2 root = null;
			int height = 0;
			int max = 0;
			int cnt = 1;
			ArrayList<Integer> parent = new ArrayList<>();
			HashMap<Integer, Integer> hm = new HashMap<>();
			public void insert(int x){
				Node2 n = new Node2();
				n.data = x;
				if(root==null){
					root = n;
				}
				else{
					Node2 temp = root,temp2 = null;
					while(temp!=null){
						temp2 = temp;
						if(x>temp.data) temp = temp.right;
						else temp = temp.left;
					}
					if(x>temp2.data) temp2.right = n;
					else temp2.left = n;
					n.parent = temp2;
					parent.add(temp2.data);
				}
			}
			public Node2 getSomething(int x, int y, Node2 n){
				if(n.data==x || n.data==y) return n;
				else if(n.data>x && n.data<y) return n;
				else if(n.data<x && n.data<y) return getSomething(x,y,n.right);
				else return getSomething(x,y,n.left);
			}
			public Node2 search(int x,Node2 n){
				if(x==n.data){
					max = Math.max(max, n.data);
					return n;
				}
				if(x>n.data){
					max = Math.max(max, n.data);
					return search(x,n.right);
				}
				else{
					max = Math.max(max, n.data);
					return search(x,n.left);
				}
			}
			public int getHeight(Node2 n){
				if(n==null) return 0;
				height = 1+ Math.max(getHeight(n.left), getHeight(n.right));
				return height;
			}
		}
		static long findDiff(long[] arr, long[] brr, int m){
			int i = 0, j = 0;
			long fa = 1000000000000L;
			while(i<m && j<m){
				long x = arr[i]-brr[j];
				if(x>=0){
					if(x<fa) fa = x;
					j++;
				}
				else{
					if((-x)<fa) fa = -x;
					i++;
				}
			}
			return fa;
		}
		public static long max(long x, long y, long z){
			if(x>=y && x>=z) return x;
			if(y>=x && y>=z) return y;
			return z;
		}
		
		public static void seive(long n){
			b = new boolean[(int) (n+1)];
			Arrays.fill(b, true);
			for(int i = 2;i*i<=n;i++){
				if(b[i]){
					for(int p = 2*i;p<=n;p+=i){
						b[p] = false;
					}
				}
			}
		}
		static long modInverse(long a, long mOD2){
		            return  power(a, mOD2-2, mOD2);
		}
		static long power(long x, long y, long m)
		{
		    if (y == 0)
		        return 1;
		    long p = power(x, y/2, m) % m;
		    p = (p * p) % m;
		 
		    return (y%2 == 0)? p : (x * p) % m;
		}
		static long power2(long x,BigInteger y,long m){
			long ans = 1;
			BigInteger two = new BigInteger("2");
			while(y.compareTo(BigInteger.ZERO)>0){
				if(y.getLowestSetBit()==y.bitCount()){
					x = (x*x)%MOD;
					y = y.divide(two);
				}
				else{
					ans = (ans*x)%MOD;
					y = y.subtract(BigInteger.ONE);
				}
			}
			return ans;
		}
		static BigInteger power2(BigInteger x, BigInteger y, BigInteger m){
			BigInteger ans = new BigInteger("1");
			BigInteger one  = new BigInteger("1");
			BigInteger two  = new BigInteger("2");
			BigInteger zero  = new BigInteger("0");
			while(y.compareTo(zero)>0){
				//System.out.println(y);
				if(y.mod(two).equals(one)){
					ans = ans.multiply(x).mod(m);
					y = y.subtract(one);
				}
				else{
					x = x.multiply(x).mod(m);
					y = y.divide(two);
				}
			}
			return ans;
		}
		static BigInteger power(BigInteger x, BigInteger y, BigInteger m)
		{
		    if (y.equals(0))
		        return (new BigInteger("1"));
		    BigInteger p = power(x, y.divide(new BigInteger("2")), m).mod(m);
		    p = (p.multiply(p)).mod(m);
		 
		    return (y.mod(new BigInteger("2")).equals(0))? p : (p.multiply(x)).mod(m);
		}
		static long d,x,y;
		public static void extendedEuclidian(long a, long b){
			if(b == 0) {
		        d = a;
		        x = 1;
		        y = 0;
		    }
		    else {
		        extendedEuclidian(b, a%b);
		        int temp = (int) x;
		        x = y;
		        y = temp - (a/b)*y;
		    }
		}
		
		public static long gcd(long n, long m){
			if(m!=0) return gcd(m,n%m);
			else return n;
		}
		
		
		public static class FasterScanner {
			private byte[] buf = new byte[1024];
			private int curChar;
			private int numChars;
	 
			public int read() {
				if (numChars == -1)
					throw new InputMismatchException();
				if (curChar >= numChars) {
					curChar = 0;
					try {
						numChars = System.in.read(buf);
					} catch (IOException e) {
						throw new InputMismatchException();
					}
					if (numChars <= 0)
						return -1;
				}
				return buf[curChar++];
			}
	 
			public String nextLine() {
				int c = read();
				while (isSpaceChar(c))
					c = read();
				StringBuilder res = new StringBuilder();
				do {
					res.appendCodePoint(c);
					c = read();
				} while (!isEndOfLine(c));
				return res.toString();
			}
	 
			public String nextString() {
				int c = read();
				while (isSpaceChar(c))
					c = read();
				StringBuilder res = new StringBuilder();
				do {
					res.appendCodePoint(c);
					c = read();
				} while (!isSpaceChar(c));
				return res.toString();
			}
	 
			public long nextLong() {
				int c = read();
				while (isSpaceChar(c))
					c = read();
				int sgn = 1;
				if (c == '-') {
					sgn = -1;
					c = read();
				}
				long res = 0;
				do {
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = read();
				} while (!isSpaceChar(c));
				return res * sgn;
			}
	 
			public int nextInt() {
				int c = read();
				while (isSpaceChar(c))
					c = read();
				int sgn = 1;
				if (c == '-') {
					sgn = -1;
					c = read();
				}
				int res = 0;
				do {
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = read();
				} while (!isSpaceChar(c));
				return res * sgn;
			}
		        
		    public int[] nextIntArray(int n) {
		        return nextIntArray(n, 0);
		    }
		    
		    public int[] nextIntArray(int n, int off) {
		    	int[] arr = new int[n + off];
		    	for (int i = 0; i < n; i++) {
		    		arr[i + off] = nextInt();
		    	}
		    	return arr;
		    }
		    
		    public long[] nextLongArray(int n) {
		    	return nextLongArray(n, 0);
		    }
	        
			public long[] nextLongArray(int n, int off) {
			    long[] arr = new long[n + off];
			    for (int i = 0; i < n; i++) {
			        arr[i + off] = nextLong();
			    }
			    return arr;
			}
	 
		    private boolean isSpaceChar(int c) {
				return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
			}
	 
			private boolean isEndOfLine(int c) {
				return c == '\n' || c == '\r' || c == -1;
			}
		}
	}   