#include <bits/stdc++.h>
using pii = std::pair<int, int>;
using ll = long long;
int const MAXN = 111111;
ll const inf = 1LL << 62;
ll S, F, T;
int N;
ll a[MAXN];
ll far[MAXN];
int main(int argc, char** argv) {
  std::ios_base::sync_with_stdio(false);
  std::cin >> S >> F >> T;
  std::cin >> N;
  far[0] = S;
  std::map<ll, pii> all;
  for (int n = 1; n <= N; ++n) {
    std::cin >> a[n];
    far[n] = std::max(far[n - 1] + T, a[n] + T);
    if (all.find(a[n]) == all.end())
      all[a[n]] = pii(n, n);
    else
      all[a[n]] = pii(all[a[n]].first, n);
  }
  if (far[N] <= F - T) {
    std::cout << F - T << std::endl;
    return 0;
  }
  if (a[1] > S) {
    std::cout << S << std::endl;
    return 0;
  }
  ll best = S, time = 0;
  for (auto const& pr : all) {
    int x = pr.second.first;
    if (pr.first - 1 > F - T) break;
    ll here = 0;
    if (all.find(pr.first - 1) == all.end()) {
      here = std::max(S, far[x - 1]) - (pr.first - 1);
    } else {
      here = std::max(S, far[all[pr.first - 1].second]) - (pr.first - 1);
    }
    if (here < best) {
      best = here;
      time = pr.first - 1;
    }
  }
  std::cout << time << std::endl;
}
