#include <bits/stdc++.h>
int main() {
  int *array_a;
  int n;
  int fl = 1;
  scanf("%d", &n);
  array_a = (int *)malloc(sizeof(int) * n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &array_a[i]);
  }
  int min = array_a[0];
  for (int i = 0; i < n; i++) {
    if (array_a[i] == 0) {
      fl = 0;
      break;
    } else if (array_a[i] < min)
      min = array_a[i];
  }
  if (fl) {
    for (int i = 0; i < n; i++) {
      if (array_a[i] % min != 0) {
        fl = 0;
        break;
      }
    }
  }
  if (fl)
    printf("%d", min);
  else
    printf("-1");
  return 0;
}
