Language: C++

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i64 = int_fast64_t;
constexpr i64 MAX = 510000;
constexpr i64 MOD = 1000000007;
template <typename T>
class modcul
{

public:
    i64 a;

    constexpr modcul(const i64 x = 0) noexcept : a(x % MOD) {}
    constexpr i64 &value() noexcept { return a; }
    constexpr const i64 &value() const noexcept { return a; }
    constexpr modcul operator+(const modcul rhs) const noexcept
    {
        return modcul(*this) += rhs;
    }
    constexpr modcul operator-(const modcul rhs) const noexcept
    {
        return modcul(*this) -= rhs;
    }
    constexpr modcul operator*(const modcul rhs) const noexcept
    {
        return modcul(*this) *= rhs;
    }
    constexpr modcul operator/(const modcul rhs) noexcept
    {
        return modcul(*this) /= rhs;
    }
    constexpr modcul &operator+=(const modcul rhs) noexcept
    {
        a += rhs.a;
        if (a >= MOD)
        {
            a -= MOD;
        }
        return *this;
    }
    constexpr modcul &operator-=(const modcul rhs) noexcept
    {
        if (a < rhs.a)
        {
            a += MOD;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modcul &operator*=(const modcul rhs) noexcept
    {
        a = a * rhs.a % MOD;
        return *this;
    }
    constexpr modcul &operator/=(const modcul rhs) noexcept
    {
        i64 exp = MOD - 2;
        while (exp)
        {
            if (exp % 2)
            {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    i64 fac[MAX], finv[MAX], inv[MAX];
    void COMninit()
    {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++)
        {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    i64 COMn(T n, T k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

vector<pair<i64,i64>> prime_factorize(i64 N)
{
    vector<pair<i64,i64>> res;
    for (i64 a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        i64 ex = 0;
        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }

        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}
i64 modpow(i64 a, i64 n, i64 mod)
{
    i64 res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 n;
    cin >> n;
    vector<i64> a(n);
    vector<i64> f(1100000, 0);
    for (i64 i = 0; i < n; i++)
    {
        cin >> a[i];
        auto fs = prime_factorize(a[i]);
        for (auto v : fs)
            f[v.first] = max<i64>(f[v.first], v.second);
    }
    modcul<i64> LCM = 1;
    for (ll i = 2; i < 1100000; i++)
    {
        LCM *= modpow(i, f[i], 1000000007);
    }
    modcul<i64> ans = 0;
    for (auto A : a)
    {
        ans += LCM / A;
    }
    cout << ans.a << endl;
}


Compiler output:
a.cc: In instantiation of 'constexpr modcul<T>& modcul<T>::operator/=(modcul<T>) [with T = long int]':
a.cc:34:30:   required from 'constexpr modcul<T> modcul<T>::operator/(modcul<T>) [with T = long int]'
   34 |         return modcul(*this) /= rhs;
      |                ~~~~~~~~~~~~~~^~~~~~
a.cc:153:22:   required from here
  153 |         ans += LCM / A;
      |                      ^
a.cc:68:17: error: passing 'const modcul<long int>' as 'this' argument discards qualifiers [-fpermissive]
   68 |             rhs *= rhs;
      |             ~~~~^~~~~~
a.cc:54:23: note:   in call to 'constexpr modcul<T>& modcul<T>::operator*=(modcul<T>) [with T = long int]'
   54 |     constexpr modcul &operator*=(const modcul rhs) noexcept
      |                       ^~~~~~~~