#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const long long oo = 1e18;
const long long MIN31 = -2147483648;
long long n, s, e, t;
long long a[110000], b[110000];
int main() {
  ios::sync_with_stdio(0);
  cin >> s >> e >> t;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n == 0) {
    cout << s << endl;
    return 0;
  }
  b[0] = max(s, a[0]) + t;
  for (int i = 1; i < n; i++) {
    b[i] = max(a[i], b[i - 1]) + t;
  }
  long long r = oo, res = -1;
  long long served, wait;
  if (a[0] > 0) {
    served = max(s, a[0] - 1);
    wait = served - (a[0] - 1);
    if (wait < r) {
      r = wait;
      res = a[0] - 1;
    }
  }
  if (s < a[0]) {
    cout << s << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] == a[i - 1]) continue;
    if (a[i] <= 0) continue;
    served = max(s, a[i] - 1);
    served = max(served, b[i - 1]);
    wait = served - (a[i] - 1);
    if (served + t > e) continue;
    if (wait < r) {
      r = wait;
      res = a[i] - 1;
    }
  }
  served = b[n - 1];
  wait = 0;
  if (served + t <= e && wait < r) {
    res = b[n - 1];
  }
  cout << res << endl;
}
