#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  cin >> n >> m;
  int lower = 0;
  int ld = 200;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    lower = max(a, lower);
    ld = min(2 * a, ld);
  }
  lower = max(lower, ld);
  for (int i = 0; i < m; i++) {
    cin >> a;
    if (a <= lower) {
      lower = -1;
    }
  }
  cout << lower << endl;
  return 0;
}
