#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int N = 1e3 + 6;
const int MD = 1e5 * 4;
void solve() {}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i <= n - 1; i++) {
    int t;
    cin >> t;
    a.push_back(t);
  }
  sort(a.begin(), a.end());
  int the_one = a[0];
  for (int i = 1; i <= n - 1; i++) {
    if (a[i] % the_one == 0)
      continue;
    else
      return cout << -1 << '\n', 0;
  }
  cout << the_one << '\n';
  return 0;
}
