#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  return gcd(b, a % b);
}
int arrgcd(int a[], int size) {
  int t = a[0];
  for (int i = 1; i < size; i++) {
    t = gcd(t, a[i]);
    if (t == 1) return 1;
  }
  return t;
}
int main() {
  int n, t = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1) t = 1;
  }
  sort(a, a + n);
  t = arrgcd(a, n);
  if (t != a[0]) t = -1;
  cout << t << endl;
}
