#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long n;
  cin >> n;
  map<long long, bool> mymap;
  long long ans;
  cin >> ans;
  mymap[ans] = 1;
  n--;
  while (n--) {
    long long a;
    cin >> a;
    mymap[a] = 1;
    ans = gcd(ans, a);
  }
  if (mymap[ans] == 1)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
