Language: C++

#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define Rep(i, n) for (int i = 1; i <=int(n); i++)
#define range(x) begin(x), end(x)
#ifdef __LOCAL_DEBUG__
#define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__)
#else
#define _debug(...) ((void) 0)
#endif
typedef long long LL;
typedef unsigned long long ULL;

int n;
LL a[10005];

inline LL mod(LL x, LL p) {
    return (x % p + p) % p;
}

LL eval(LL x, LL p) {
    x %= p;
    LL cur = 1, ans = 0;
    for (int i = 0; i <= n; i++) {
        ans = (ans + cur * mod(a[i], p)) % p;
        cur = cur * x % p;
    }
    return ans;
}

bool check(LL p) {
    for (int i = 0; i <= max(n, p-1); i++) if (eval(i, p)) return false;
    return true;
}

mt19937 gen(time(NULL));

int isprime(int x) {
    if (x < 2) return false;
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0) return false;
    return true;
}

set<int> ans;
int main() {
    scanf("%d", &n);
    for (int i = n; i >= 0; i--) scanf("%lld", a + i);
    LL x = abs(accumulate(a, a + n + 1, 0ll, __gcd<LL>));
    if (isprime(x)) ans.insert(x);
    for (int i = 2; i * i <= x; i++) {
        if (x % i) continue;
        if (isprime(i)) ans.insert(i);
        if (isprime(x / i)) ans.insert(x / i);
    }
    for (int i = 2; i <= n; i++) {
        if (!isprime(i)) continue;
        rep (_, 10) {
            LL x = gen() % i;
            if (eval(x, i)) goto cont;
        }
        if (check(i)) ans.insert(i);
        cont:;
    }
    for (int x : ans) printf("%d\n", x);
    return 0;
}

Compiler output:
a.cc: In function 'bool check(LL)':
a.cc:34:29: error: no matching function for call to 'max(int&, LL)'
   34 |     for (int i = 0; i <= max(n, p-1); i++) if (eval(i, p)) return false;
      |                          ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:34:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'LL' {aka 'long long int'})
   34 |     for (int i = 0; i <= max(n, p-1); i++) if (eval(i, p)) return false;
      |                          ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:34:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |     for (int i = 0; i <= max(n, p-1); i++) if (eval(i, p)) return false;
      |                          ~~~^~~~~~~~