#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    int a[100], b[100];
    for (int i = 0; i < (int)(n); i++) scanf("%d", a + i);
    for (int i = 0; i < (int)(m); i++) scanf("%d", b + i);
    int a0 = 101, a1 = 0, b1 = 101;
    for (int i = 0; i < (int)(n); i++) {
      a0 = min(a0, a[i]);
      a1 = max(a1, a[i]);
    }
    for (int i = 0; i < (int)(m); i++) b1 = min(b1, b[i]);
    int ans = max(a0 * 2, a1);
    if (ans >= b1)
      puts("-1");
    else
      printf("%d\n", ans);
  }
  return 0;
}
