#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  auto it = min_element(v.begin(), v.end());
  swap(v[0], *(it));
  for (int i = 1; i < n; i++) {
    if (v[i] % v[0] != 0) {
      cout << -1;
      return 0;
    }
  }
  cout << v[0];
}
