#include <bits/stdc++.h>
using namespace std;
bool isPraim(int n);
long long even_or_odd(vector<long long> EO);
int main() {
  int n, mn = INT_MAX;
  cin >> n;
  vector<int> V(n);
  for (int i = 0; i < n; i++) {
    cin >> V[i];
    mn = min(mn, V[i]);
  }
  for (int i = 0; i < n; i++) {
    if (V[i] % mn != 0) {
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << mn << endl;
}
