#include <bits/stdc++.h>
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int a[100002];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  long long int g = gcd(a[0], a[1]);
  for (int i = 2; i < n; i++) {
    g = gcd(g, a[i]);
  }
  int min = a[0];
  for (int i = 0; i < n; i++) {
    if (min > a[i]) min = a[i];
  }
  if (min == g) {
    printf("%lld\n", g);
  } else {
    printf("-1\n");
  }
}
