#include <bits/stdc++.h>
using namespace std;
int nextInt() {
  int x;
  scanf("%d", &x);
  return x;
}
const int MAX_N = 1e5 + 100;
int arr[MAX_N];
int main() {
  int n = nextInt();
  for (int i = 0; i < n; ++i) arr[i] = nextInt();
  sort(arr, arr + n);
  for (int i = 1; i < n; ++i) {
    if (arr[i] % arr[0] != 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << arr[0] << endl;
  return 0;
}
