#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int MAXN = 100005;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
long long res, ans;
void update(long long wait, long long time) {
  if (ans == -1 || ans > wait) ans = wait, res = time;
}
int main() {
  long long s, f, t;
  scanf("%lld%lld%lld", &s, &f, &t);
  int n;
  scanf("%d", &n);
  long long now = s;
  res = ans = -1;
  for (int i = 1; i <= n; ++i) {
    long long x;
    scanf("%lld", &x);
    if (now >= x) {
      if (now + t > f) break;
      update(now - x + 1, x - 1);
      now += t;
    } else {
      update(0, now);
      break;
    }
  }
  if (now + t <= f) update(0, now);
  printf("%lld", res);
  return 0;
}
