#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int minA = 105, maxA = 0, minB = 105;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    minA = min(minA, a);
    maxA = max(maxA, a);
  }
  for (int i = 0; i < m; i++) {
    int b;
    cin >> b;
    minB = min(minB, b);
  }
  maxA = max(maxA, 2 * minA);
  if (minB <= maxA) {
    cout << -1 << endl;
  } else {
    cout << maxA;
  }
}
