Răspuns:
#include <iostream>
#include <fstream>
#include<vector>
using namespace std;
int main() {
ifstream f("numere.in");
int a, n, ok = 1, i, m;
vector<int>v;
f >> n;
m = n;
while (n != 0)
{
f >> a;
for (int div = 1; div <= a / 2; div++)
if ((a % div == 0) && (a != 1))
v.push_back(div);
v.push_back(a);
n--;
}
i = v.size() - 1;
while (ok != m)
{
ok = 1;
for (int j = i - 1; j >= 0; j--)
if (v[i] == v[j])
ok++;
i--;
}
cout << v[i + 1];
}