Language: C++

#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-6
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e4+10;

ll n;
ll a[maxn];

inline long long read() {
    long long tmp=0, fh=1; char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
    while (c>='0'&&c<='9') tmp=tmp*10+c-48, c=getchar();
    return tmp*fh;
}

ll num[1000010];
ll prime[1000010];	//下标从1开始
bool not_prime[1000010];

int sieve(int n){	//把2到n内所有素数筛选出来 
    int p = 0;
    for (int i = 2; i <= n; ++i){
        if(!not_prime[i])
           prime[++p] = i;
        for(int j = 1; j <= p&&i*prime[j]<=n; j++){
        	not_prime[i*prime[j]] = true;	//把比最小素因子的素数的倍数筛除 
        	if(i%prime[j]==0) break;	//已找到最小素因子	
		}
    }
    return p;   //  返回素数个数
}

void pri_fac(ll x){
	for(int i=1;prime[i]<=x;i++){
		int y =prime[i];
		if(x%y==0){
			int p=0;
			while(x%y==0){
				x/=y;
				p++;
			}
			num[y] = max(p,num[y]);
		}
	}
}

ll	qpow(ll n,ll b){
	ll res=1;
	while(b){
		if(b&1) res = res*n%mods;
		n=n*n%mods;
		b>>=1;
	} 
	return res;
}

int main() {
	n=read();
	sieve(1000000);
	ll maa=0;
	F(i,1,n){
		a[i]=read();
		//a[i] = rand()%1000000+1;
		maa = max(a[i],maa); 
		if(a[i]!=1) pri_fac(a[i]);
	}
	ll sum=1;
	F(i,1,maa){
		sum=sum*qpow(i,num[i])%mods;
	}
	ll ans = 0;
	F(i,1,n){
		ans = ans+qpow(a[i],mods-2);
		ans%=mods;
	}
	ans=ans*sum%mods;
	printf("%lld\n",ans);
}

Compiler output:
a.cc: In function 'void pri_fac(ll)':
a.cc:52:37: error: no matching function for call to 'max(int&, ll&)'
   52 |                         num[y] = max(p,num[y]);
      |                                  ~~~^~~~~~~~~~
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:1:
/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:52:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   52 |                         num[y] = max(p,num[y]);
      |                                  ~~~^~~~~~~~~~
/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:52:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |                         num[y] = max(p,num[y]);
      |                                  ~~~^~~~~~~~~~