#include <bits/stdc++.h>
using namespace std;
long long ar[100005], br[100005];
int main() {
  long long start, cost = 2e18, cur, ans = 0, finish, tm, a, b, t;
  int n;
  scanf("%lld %lld %lld", &start, &finish, &tm);
  scanf("%d", &n);
  br[0] = start;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &ar[i]);
    br[i] = max(br[i - 1], ar[i]) + tm;
  }
  ar[n + 1] = br[n] + 1;
  ans = start;
  for (int i = 1; i <= n + 1; i++) {
    if (ar[i] - 1 >= br[i - 1])
      t = 0;
    else
      t = br[i - 1] - ar[i] + 1;
    if (cost > t && ar[i] - 1 <= finish - tm && ar[i] - 1 >= 0) {
      cost = t;
      ans = ar[i] - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
