#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, minc = 1000, maxc = -1, minw = 1000, a, ans;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    minc = min(a, minc);
    maxc = max(a, maxc);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &a);
    minw = min(minw, a);
  }
  ans = max(maxc, 2 * minc);
  if (ans >= minw)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}
