#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
vector<int> g;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (int i = 2; i <= n; i++) g.push_back(a[i]);
  int i = g.size() - 1;
  while (i >= 0) {
    if (g[i] % a[1] == 0) {
      g.pop_back();
      i--;
      continue;
    } else
      break;
  }
  if (g.empty())
    cout << a[1];
  else
    cout << -1;
}
