Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod =  1e9 + 7;
const int maxn = 10'000 + 5;
const int maxv = 1'000'000 + 5;
ll arr[maxn], pf[maxv];
ll modpow(ll base, ll power) {
    ll res = 1;
    while (power) {
        if (power & 1)
            res = res * base % mod;
        base = base * base % mod;
        power >>= 1;
    }
    return res;
}
void fac(int num) {
    int cnt = 0;
    if (num % 2 == 0) {
        while (num % 2 == 0) {
            ++cnt;
            num /= 2;
        }
        pf[2] = max(pf[2], cnt);
    }
    int bound = sqrt(num) + 1;
    for (int i = 3; i <= bound && num <= i; i += 2) {
        if (num % i == 0) {
            cnt = 0;
            while (num % i == 0) {
                ++cnt;
                num /= i;
            }
            pf[i] = max(pf[i], cnt);
        }
    }
    if (num > 2)
        pf[num] = max(pf[num], 1);
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        fac(arr[i]);
    }
    ll lcm = 1;
    for (int i = 2; i < maxv; ++i)
        lcm = lcm * modpow(i, pf[i]) % mod;
    ll res = 0;
    for (int i = 0; i < n; ++i)
        res = (res + lcm * modpow(arr[i], mod - 2) % mod) % mod;
    cout << res << '\n';
    return 0;
}

Compiler output:
a.cc: In function 'void fac(int)':
a.cc:25:20: error: no matching function for call to 'max(ll&, int&)'
   25 |         pf[2] = max(pf[2], cnt);
      |                 ~~~^~~~~~~~~~~~
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:25:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   25 |         pf[2] = max(pf[2], cnt);
      |                 ~~~^~~~~~~~~~~~
/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:25:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |         pf[2] = max(pf[2], cnt);
      |                 ~~~^~~~~~~~~~~~
a.cc:35:24: error: no matching function for call to 'max(ll&, int&)'
   35 |             pf[i] = max(pf[i], cnt);
      |                     ~~~^~~~~~~~~~~~
/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:35:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   35 |             pf[i] = max(pf[i], cnt);
      |                     ~~~^~~~~~~~~~~~
/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
/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:35:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   35 |             pf[i] = max(pf[i], cnt);
      |                     ~~~^~~~~~~~~~~~
a.cc:39:22: error: no matching function for call to 'max(ll&, int)'
   39 |         pf[num] = max(pf[num], 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:39:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   39 |         pf[num] = max(pf[num], 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
/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:39:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   39 |         pf[num] = max(pf[num], 1);
      |                   ~~~^~~~~~~~~~~~