#include <bits/stdc++.h>
using namespace std;
long long int __gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return __gcd(b, a % b);
}
int main() {
  int n;
  cin >> n;
  long long int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long int gcd = arr[0];
  for (int i = 1; i < n; i++) gcd = __gcd(gcd, arr[i]);
  int c = 1;
  for (int i = 0; i < n; i++) {
    if (arr[i] == gcd) {
      cout << gcd;
      c = 0;
      break;
    }
  }
  if (c) cout << -1;
}
