#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t, r = 0, r1 = 0, r2 = 0, k = 0, a, b, c = 0, m, d = 0, n, e, f, x = 0, g,
         p = 0, q = 0, y = 0, z = 0;
  vector<long long> v;
  vector<long long> u;
  set<long long> s;
  std::vector<int>::iterator it;
  string s1, s2, s3, s4;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  ;
  x = v[0];
  for (int i = 1; i < t; i++) {
    if (v[i] % x == 0) {
      c++;
    }
  }
  if (c == (t - 1)) {
    cout << v[0] << endl;
  } else {
    cout << -1 << endl;
  }
}
