#include <bits/stdc++.h>
using namespace std;
class AKsushaAndArray {
 public:
  void solve(std::istream &in, std::ostream &out) {
    int n;
    in >> n;
    int a[n];
    for (auto &data : a) in >> data;
    sort(a, a + n);
    int number = a[0];
    for (int i = 1; i < n; i++) {
      if (a[i] % number != 0) {
        out << -1 << endl;
        return;
      }
    }
    out << number << endl;
  }
};
int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(nullptr);
  AKsushaAndArray solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
