#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1e5 + 100;
int a[N];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int s = 1;
  while (s < n and a[s] == a[0]) s++;
  if (s == n) return cout << a[0] << endl, 0;
  for (int i = s; i < n; i++)
    if (a[i] % a[0] != 0) return cout << -1 << endl, 0;
  return cout << a[0] << endl, 0;
}
