Language: C++

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
long long n,p,lcm,tot;
long long arr[100001];
long long num[1000001];
long long power(long long a,long long b){
    long long res=1;
    while (b>0){
        if (b%2==1) res=(res*a)%p;
        b/=2;
        a=(a*a)%p;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    p=1e9+7;
    for (int i=1;i<=n;i++) cin>>arr[i];
    for (long long i=1;i<=n;i++){
        long long cur=arr[i];
        for (long long j=2;j*j<=arr[i];j++){
            long long res=0;
            while (cur%j==0){
                res++;
                cur/=j;;
            }
            num[j]=max(num[j],res);
        }
        if (cur!=1){
            num[cur]=max(num[cur],1);
        }
    }
    lcm=1;
    for (long long i=1;i<=1000000;i++){
        lcm*=power(i,num[i]);
        lcm%=p;
    }
    for (long long i=1;i<=n;i++){
        tot+=lcm*power(arr[i],p-2);
        tot%=p;
    }
    cout<<tot;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:25: error: no matching function for call to 'max(long long int&, int)'
   34 |             num[cur]=max(num[cur],1);
      |                      ~~~^~~~~~~~~~~~
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:34:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   34 |             num[cur]=max(num[cur],1);
      |                      ~~~^~~~~~~~~~~~
/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:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   34 |             num[cur]=max(num[cur],1);
      |                      ~~~^~~~~~~~~~~~
a.cc:37:5: error: reference to 'lcm' is ambiguous
   37 |     lcm=1;
      |     ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58:
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:5:15: note:                 'long long int lcm'
    5 | long long n,p,lcm,tot;
      |               ^~~
a.cc:39:9: error: reference to 'lcm' is ambiguous
   39 |         lcm*=power(i,num[i]);
      |         ^~~
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:5:15: note:                 'long long int lcm'
    5 | long long n,p,lcm,tot;
      |               ^~~
a.cc:40:9: error: reference to 'lcm' is ambiguous
   40 |         lcm%=p;
      |         ^~~
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:5:15: note:                 'long long int lcm'
    5 | long long n,p,lcm,tot;
      |               ^~~
a.cc:43:14: error: reference to 'lcm' is ambiguous
   43 |         tot+=lcm*power(arr[i],p-2);
      |              ^~~
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:5:15: note:                 'long long int lcm'
    5 | long long n,p,lcm,tot;
      |               ^~~