#include <bits/stdc++.h>
using namespace std;
int A[200], B[200];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < m; i++) cin >> B[i];
  for (int v = 1; v <= 200; v++) {
    int ok = 1;
    for (int i = 0; i < n; i++)
      if (A[i] > v) ok = 0;
    if (ok) {
      ok = 0;
      for (int i = 0; i < n; i++)
        if (A[i] * 2 <= v) ok = 1;
      for (int i = 0; i < m; i++)
        if (B[i] <= v) ok = 0;
    }
    if (ok) {
      cout << v << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
