#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double pi = acos(-1.0);
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int m;
  cin >> m;
  int a[n], b[m];
  for (int i = 0; i < n; i++) cin >> a[i];
  ;
  for (int i = 0; i < m; i++) cin >> b[i];
  ;
  sort(a, a + n);
  sort(b, b + m);
  int k = a[0] * 2;
  k = max(k, a[n - 1]);
  if (b[0] <= k)
    cout << -1 << endl;
  else
    cout << k << endl;
}
