#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int ans[n], wrong[m];
  int mi = INT_MAX, ma = INT_MIN;
  for (int i = 0; i < n; i++) {
    cin >> ans[i];
    if (ma < ans[i]) {
      ma = ans[i];
    }
    if (mi > ans[i]) {
      mi = ans[i];
    }
  }
  int mi2 = INT_MAX;
  for (int j = 0; j < m; j++) {
    cin >> wrong[j];
    if (mi2 > wrong[j]) {
      mi2 = wrong[j];
    }
  }
  int val = max(2 * mi, ma);
  if (val < mi2) {
    cout << val;
  } else {
    cout << -1;
  }
  return 0;
}
