#include <bits/stdc++.h>
using namespace std;
int n, m, a[100], b[100], answer;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> 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);
  answer = max(a[0] * 2, a[n - 1]);
  answer = b[0] <= answer ? -1 : answer;
  cout << answer << '\n';
}
