#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a[n + 1], mn = 1000007001;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mn = min(mn, a[i]);
  }
  sort(a, a + n);
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (a[i] % mn == 0)
      continue;
    else
      ok = false;
  }
  if (!ok)
    cout << -1 << endl;
  else
    cout << mn << endl;
  return 0;
}
