#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int arr[100001];
  int arr1[100001];
  for (int i = 0; i < n; cin >> arr[i++])
    ;
  for (int i = 0; i < k; cin >> arr1[i++])
    ;
  sort(arr, arr + n);
  sort(arr1, arr1 + k);
  int res;
  if (2 * arr[0] >= arr[n - 1])
    res = 2 * arr[0];
  else
    res = arr[n - 1];
  if (arr1[0] <= res || res < 0)
    cout << -1;
  else
    cout << res;
}
