#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, v, n, m, p, c, d;
  cin >> n >> m;
  int arr[n], brr[m];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < m; i++) {
    cin >> brr[i];
  }
  v = *min_element(arr, arr + n);
  p = *max_element(arr, arr + n);
  c = *min_element(brr, brr + m);
  d = max(2 * v, p);
  if (d < c) {
    cout << d;
  } else
    cout << "-1";
  return 0;
}
