#include <bits/stdc++.h>
using namespace std;
long gcd(long a, long b) {
  if (a < b) {
    swap(a, b);
  }
  while (b != 0) {
    long temp = b;
    b = a % b;
    a = temp;
  }
  return a;
}
int main() {
  long n;
  cin >> n;
  long arr[n];
  for (long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  long ans = arr[n - 1];
  for (long i = n - 2; i >= 0; i--) {
    ans = gcd(ans, arr[i]);
  }
  if (ans == arr[0]) {
    cout << ans;
  } else {
    cout << "-1";
  }
}
