#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[123], b[123];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < m; i++) scanf("%d", &b[i]);
  sort(b, b + m);
  int v, p, c, temp;
  v = a[0];
  p = a[n - 1];
  c = b[0];
  temp = max(2 * v, p);
  if (temp < c)
    printf("%d\n", temp);
  else
    printf("-1\n");
  return 0;
}
