#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int mn = INT_MAX;
  int arr[100100];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mn = min(mn, arr[i]);
  }
  for (int i = 0; i < n; i++) {
    if (arr[i] % mn != 0) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << mn << '\n';
  return 0;
}
