#include <bits/stdc++.h>
int mdc(int a, int b) {
  while (a != 0 && b != 0) {
    if (a > b)
      a %= b;
    else
      b %= a;
  }
  return a + b;
}
int n, a[100100];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int d = a[0];
  for (int i = 0; i < n; i++) d = mdc(d, a[i]);
  int flag = 0;
  for (int i = 0; i < n; i++)
    if (d == a[i]) flag = 1;
  if (flag)
    printf("%d\n", d);
  else
    printf("-1\n");
  return 0;
}
