#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a[100000], b[100000] = {0}, c = 0, d, i, j, n,
                       MIN = 10000000 * 10000, MAX = 0;
  map<int, int> mp;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
    MIN = min(MIN, a[i]);
  }
  for (i = 0; i < n; i++) {
    if (a[i] % MIN != 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << MIN << endl;
  return 0;
}
