#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12 + 10;
const int N = 1e5 + 10;
long long a[N];
int main() {
  long long n, m, s, e, t;
  while (cin >> s >> e >> t >> n) {
    bool f = false;
    long long ans = -1;
    long long dis = INF;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
      if (a[i] > s && s + t <= e) {
        f = true;
        break;
      }
      if (a[i] != a[i - 1] && a[i] - 1 + t <= e && s - a[i] + 1 < dis) {
        ans = a[i] - 1;
        dis = s - a[i] + 1;
      }
      s += t;
    }
    if (f == true) {
      cout << s << endl;
      continue;
    }
    if (s + t <= e) ans = s;
    cout << ans << endl;
  }
  return 0;
}
