#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using intpair = pair<int, int>;
using llpair = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
pair<ll, ll> m[100001];
int main() {
  ll s, f, t, n, a;
  cin >> s >> f >> t >> n;
  if (n == 0) {
    cout << s;
    return 0;
  }
  ll k = 1e12 + 1, time = -1;
  for (ll i = 1; i <= n; i++) {
    cin >> a;
    if (i == 1) {
      if (a > s) {
        cout << s;
        return 0;
      }
      m[i] = {a, (a < s ? s + t : a + t)};
      continue;
    }
    if (m[i - 1].second < a && m[i - 1].second + t <= f) {
      cout << m[i - 1].second;
      return 0;
    }
    if (m[i - 1].second == a && m[i - 1].second + t <= f) {
      time = m[i - 1].second - 1;
      k = 1;
    }
    m[i] = {a, m[i - 1].second + t};
  }
  if (m[n].second + t <= f) {
    cout << m[n].second;
    return 0;
  }
  if (k == 1) {
    cout << time;
    return 0;
  }
  if (m[1].first != 0) {
    k = s - (m[1].first - 1);
    time = m[1].first - 1;
  }
  for (ll i = 1; i < n; i++) {
    if (m[i].first != m[i + 1].first) {
      if (m[i].second - (m[i + 1].first - 1) < k &&
          (m[i + 1].first - 1 + t <= f)) {
        k = m[i].second - (m[i + 1].first - 1);
        time = m[i + 1].first - 1;
      }
    }
  }
  cout << time;
}
