#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int pass[n], fail[k];
  int q, w, r, t;
  t = 0;
  int MinPass, MaxPass, MinFail;
  MinPass = 100;
  MaxPass = 0;
  MinFail = 100;
  for (q = 0; q < n; q++) {
    scanf("%d", &pass[n]);
    if (pass[n] < MinPass) MinPass = pass[n];
    if (pass[n] > MaxPass) MaxPass = pass[n];
  }
  for (w = 0; w < k; w++) {
    scanf("%d", &fail[k]);
    if (fail[k] < MinFail) MinFail = fail[k];
  }
  if ((MinPass * 2) >= MinFail) {
    printf("-1\n");
    return 0;
  } else if (MaxPass >= MinFail) {
    printf("-1\n");
    return 0;
  } else if ((MinPass * 2) >= MaxPass)
    t = MinPass * 2;
  else if (MaxPass > (MinPass * 2))
    t = MaxPass;
  printf("%d\n", t);
  return 0;
}
