#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cntfv = 0, cnt = 0, check;
  cin >> n;
  bool flag = false;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[0] << endl;
  } else {
    sort(a, a + n);
    for (int i = 0; i < n - 1; i++) {
      if (a[i] == a[0]) cntfv++;
    }
    check = n - cntfv + 1;
    for (int i = cntfv - 1; i < n; i++) {
      if (a[i] % a[0] != 0) {
        flag = true;
        break;
      }
    }
    if (flag == true)
      cout << -1 << endl;
    else
      cout << a[0] << endl;
  }
  return 0;
}
