#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int n = 0;
int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort((a).begin(), (a).end());
  int ans = a[0];
  for (int i = 0; i < n; ++i) {
    if (a[i] % ans) {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
