Language: C++

#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

template<ll mod=MOD>
ll modpow(ll x,ll n){
  if(n==0)return 1;
  if(n%2)return ((x%mod)*(modpow(x,n-1)%mod))%mod;
  else {
    ll half=modpow(x,n/2)%mod;
    return (half*half)%mod;
  }
}

#define int ll

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin>>N;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];

  vector<ll>B=A;
  vector<map<int,ll>>vec(N);
  for(int i=0;i<N;i++){
    for(int j=2;j*j<=A[i];j++){
      while(A[i]%j==0)A[i]/=j,vec[i][j]=(vec[i][j]+1)%MOD;
    }
    if(N!=1)vec[i][A[i]]=1;
  }

  map<int,ll>GCD;
  for(int i=0;i<N;i++){
    for(auto it:vec[i]){
      GCD[it.first]=max(GCD[it.first],it.second);
    }
  }

  ll gcd=1;
  for(auto it:GCD)gcd=(gcd*modpow(it.first,it.second))%MOD;
  gcd%=MOD;

  for(int i=0;i<N;i++)B[i]%=MOD;
  ll ans=0;
  gcd%=MOD;
  for(int i=0;i<N;i++){
    ans=(((modpow(B[i],MOD-2)*gcd)%MOD)+ans%MOD)%MOD;
  }
  cout<<max(ans%MOD,1)<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:61:12: error: no matching function for call to 'max(ll, int)'
   61 |   cout<<max(ans%MOD,1)<<endl;
      |         ~~~^~~~~~~~~~~
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:61:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   61 |   cout<<max(ans%MOD,1)<<endl;
      |         ~~~^~~~~~~~~~~
/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:61:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   61 |   cout<<max(ans%MOD,1)<<endl;
      |         ~~~^~~~~~~~~~~