#include <bits/stdc++.h>
using namespace std;
struct ASDF {
  ASDF& operator,(int& a) {
    scanf("%d", &a);
    return *this;
  }
  ASDF& operator,(long int& a) {
    scanf("%ld", &a);
    return *this;
  }
  ASDF& operator,(long long int& a) {
    scanf("%lld", &a);
    return *this;
  }
  ASDF& operator,(char& c) {
    scanf("%c", &c);
    return *this;
  }
  ASDF& operator,(double& d) {
    scanf("%lf", &d);
    return *this;
  }
  template <typename T>
  ASDF& operator,(T& a) {
    cin >> a;
    return *this;
  }
} asdf;
struct ASDFG {
  template <typename T>
  ASDFG& operator,(vector<T>& v) {
    printf("[");
    cout << v[0];
    for (int i = 1; i < int(v.size()); i++) {
      cout << ", " << v[i];
    }
    printf("]");
    return *this;
  }
  template <typename T>
  ASDFG& operator,(T x) {
    cout << x << " ";
    return *this;
  }
} asdfg;
int main() {
  int n, m;
  int correct[102], wrong[102];
  asdf, n, m;
  for (int i = 0; i < n; i++) {
    asdf, correct[i];
  }
  for (int i = 0; i < m; i++) {
    asdf, wrong[i];
  }
  sort(correct, correct + n);
  int minOfWrongAns = 1 << 29;
  for (int i = 0; i < m; i++) {
    minOfWrongAns = min(minOfWrongAns, wrong[i]);
  }
  int result = max(2 * correct[0], correct[n - 1]);
  cout << (result < minOfWrongAns ? result : -1) << endl;
}
