#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long int t, n, m, p, q, mx = 0, mi = 100, mi_w = 100;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> p;
    mx = max(mx, p);
    mi = min(mi, p);
  }
  for (int j = 1; j <= m; j++) {
    cin >> q;
    mi_w = min(mi_w, q);
  }
  for (int k = mx; k < mi_w; k++) {
    if (mi * 2 <= k) {
      cout << k;
      return 0;
    }
  }
  cout << -1;
}
