#include <bits/stdc++.h>
using namespace std;
int n, m;
int maxa = 0, mina = 1000, minb = 1000;
int temp;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> temp;
    if (maxa < temp) maxa = temp;
    if (mina > temp) mina = temp;
  }
  for (int i = 0; i < m; ++i) {
    cin >> temp;
    if (minb > temp) minb = temp;
  }
  cout << (max(2 * mina, maxa) < minb ? max(2 * mina, maxa) : -1) << endl;
  return 0;
}
