#include <bits/stdc++.h>
using namespace std;
int main() {
  int min;
  int n, a[100001];
  bool ans = true;
  scanf("%d", &n);
  scanf("%d", &a[0]);
  min = a[0];
  for (int i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    if (min > a[i]) min = a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] % min != 0) {
      ans = false;
      break;
    }
  }
  if (ans)
    printf("%d\n", min);
  else
    printf("-1\n");
}
