Language: C++

#include <bits/stdc++.h>
using namespace std;

#define MAX 1000000
#define MOD 1000000007
vector<int> p;
void prime(int A){
  for(int i=2;i<=A;i++){
    bool flag=true;
    for(int j=2;j<=sqrt(i);j++){
      if(i%j==0){
        flag=false;
        break;
      }
    }
    if(flag){
      p.push_back(i);
    }
  }
}


long int modpow(long int a,long int n,long int mod){
  long int res=1;
  while(n>0){
    if(n&1){      
      res=(res*a)%mod;
    }
    a=(a*a)%mod;
    n>>=1;
  }
  return res;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}


int main(){
  int N;
  cin>>N;
  vector<long int> A(N);
  int k=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    k=max(k,A.at(i));
  }

  vector<long int> B=A;

  prime(k);
  //COMinit();
  vector<int> p_count(p.size(),0);
  for(int i=0;i<N;i++){
    for(int j=0;j<p.size();j++){
      if(B.at(i)==1){
        break;
      }
      int count=0;
      while(B.at(i)%p.at(j)==0){
        B.at(i)/=p.at(j);
        count++;
      }
      p_count.at(j)=max(p_count.at(j),count);
    }
  }

  long int M=1;
  for(int i=0;i<p.size();i++){
    M=M*modpow(p.at(i),p_count.at(i),MOD)%MOD;
  }

  long int sum=0;
  for(int i=0;i<N;i++){
    sum=(sum+(M%MOD)*modinv(A.at(i),MOD)%MOD)%MOD;
  }
  cout<<sum<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:47:10: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&)'
   47 |     k=max(k,A.at(i));
      |       ~~~^~~~~~~~~~~
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:47:10: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   47 |     k=max(k,A.at(i));
      |       ~~~^~~~~~~~~~~
/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:47:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |     k=max(k,A.at(i));
      |       ~~~^~~~~~~~~~~