#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
int s[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
  sort(s + 1, s + 1 + n);
  for (int i = 1, j = 1; i <= n; i++) {
    if (s[i] % s[j] != 0) {
      printf("%d", -1);
      return 0;
    }
  }
  printf("%d\n", s[1]);
  return 0;
}
