#include <bits/stdc++.h>
int main() {
  int n, ara[100000], i, hcf, temp = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &ara[i]);
  }
  hcf = ara[0];
  for (i = 0; i < n; i++) {
    if (ara[i] < hcf) {
      hcf = ara[i];
    }
  }
  for (i = 0; i < n; i++) {
    if (ara[i] % hcf == 0) {
      temp += 1;
    }
  }
  if (temp == n) {
    printf("%d\n", hcf);
  } else {
    printf("-1");
  }
  return 0;
}
