#include <bits/stdc++.h>
int n, m, a, b, mna = 101, mnb = 101, mxa, mxb;
void No() { printf("-1"); }
void Yes(int n) { printf("%d", n); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n;
       i++, scanf("%d", &a), mna = std::min(mna, a), mxa = std::max(mxa, a))
    ;
  for (int i = 0; i < m; i++, scanf("%d", &b), mnb = std::min(mnb, b))
    ;
  mxa = std::max(mxa, 2 * mna);
  if (mxa >= mnb)
    No();
  else
    Yes(mxa);
  return 0;
}
