#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int minc = 99999, maxc = 0;
  for (int i = 0; i < a; ++i) {
    int x;
    cin >> x;
    minc = min(minc, x);
    maxc = max(maxc, x);
  }
  int minw = 9999;
  for (int i = 0; i < b; ++i) {
    int x;
    cin >> x;
    minw = min(minw, x);
  }
  int res = max(maxc, 2 * minc);
  if (res >= minw) res = -1;
  cout << res << endl;
  return 0;
}
