Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MOD = 1e9+7;
long long modpow(long long x, long long n, long long m = 1e9+7) {
    if (n == 0) return 1;
    if (n % 2 == 1) return (x * modpow(x, n - 1, m)) % m;
    long long t = modpow(x, n / 2, m);
    return (t * t) % m;
}

set<long long> eratosthenes_sieve(int n) {
    vector<bool> v(n + 1, true);
    if (n >= 0) { v[0] = false; }
    if (n >= 1) { v[1] = false; }
    for (int i = 2; i*i <= n; i++) {
        if (!v[i]) { continue; }
        for (int j = i+i; j <= n; j += i) { v[j] = false; }
    }
    set<long long> ret;
    if (2 <= n) ret.insert(2);
    for (int i = 3; i < n; i++) if (v[i]) ret.insert(i);
    return ret;
}

map<long long, long long> prime_factor(long long n) {
  map<long long, long long> ret;
  for(long long i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      if (ret.count(i)) ret[i]++;
      else ret[i] = 1;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e%2 == 0) { p = (p*p)%mod; e /= 2; }
            else { a = (a*p)%mod; e--; }
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using mint = ModInt<MOD>;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    long long MX = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        chmax(MX, A[i]);
    }
    
    set<long long> prime = eratosthenes_sieve(MX);
    vector<map<long long, long long>> data(N);
    /*
    for (int i = 0; i < N; i++) data[i] = prime_factor(A[i]);
    
    map<long long, long long> L;
    for (auto e : prime) {
        long long res = 0;
        for (int i = 0; i < N; i++) {
            if (data[i].count(e)) chmax(res, data[i][e]);
        }
        if (res != 0) L[e] = res;
    }
    */
    auto LCM = [=]()->mint {
        mint res = 1;
        for (auto e : prime) {
            long long a = 0;
            for (int i = 0; i < N; i++) {
                long long cnt = 0;
                while (A[i] % e == 0) {
                    A[i] /= e;
                    cnt++;
                }
                chmax(a, cnt);
            }
            if (a != 0) res *= modpow(e, a);
        }
        return res;
    };
    mint L = LCM(A);
    /*
    for (auto e : L) {
        long long a, b; tie(a, b) = e;
        long long res = modpow(a, b);
        LCM *= (mint)res;
    }
    */
    mint ans = 0;
    for (int i = 0; i < N; i++) {
        mint res = L;
        res /= (mint)A[i];
        ans += res;
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In lambda function:
a.cc:114:26: error: assignment of read-only location 'A.std::__debug::vector<long long int>::operator[](((std::__debug::vector<long long int>::size_type)i))'
  114 |                     A[i] /= e;
a.cc: In function 'int main()':
a.cc:123:17: error: no match for call to '(main()::<lambda()>) (std::__debug::vector<long long int>&)'
  123 |     mint L = LCM(A);
      |              ~~~^~~
a.cc:107:16: note: candidate: 'main()::<lambda()>'
  107 |     auto LCM = [=]()->mint {
      |                ^
a.cc:107:16: note:   candidate expects 0 arguments, 1 provided