#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> vn(100);
vector<int> vm(100);
int solve(int k) {
  int extra = 0;
  for (int i = (0); i < (n); ++i) {
    if (k < vn[i]) return 0;
    if (k >= vn[i] * 2) extra++;
  }
  for (int i = (0); i < (m); ++i) {
    if (k >= vm[i]) return 0;
  }
  return extra;
}
int main() {
  while (cin >> n >> m) {
    for (int i = (0); i < (n); ++i) cin >> vn[i];
    for (int i = (0); i < (m); ++i) cin >> vm[i];
    int k = 1;
    for (; k <= 100; k += 1) {
      if (solve(k)) {
        printf("%d\n", k);
        break;
      }
    }
    if (k > 100) puts("-1");
  }
  return 0;
}
