Language: C++

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<int64_t MOD> struct Mint {
    int64_t v;
    Mint() { v = 0; }
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

mint gcd(mint a, mint b) {
    return b.v == 0 ? a : gcd(b, a-(a/b)*b);
}

// O(√n)
map<int64_t, int64_t> prime_factor(int64_t n) {
    map<int64_t, int64_t> res;
    for(int64_t i=2; i*i<=n; i++) {
        while(n%i == 0)  res[i]++, n/=i;
    }
    if(n != 1)  res[n] = 1;
    return res;
}

int main() {
    lint n;
    cin >> n;

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;

    // 普通にやるとオーバーフローしそうなので、素因数分解した数を保持することにする
    vector<map<lint, lint>> pf(n);

    for(lint i=0; i<n; i++) {
        pf[i] = prime_factor(a[i]);
    }

    map<lint, lint> lcm;

    for(lint i=0; i<n; i++) {
        for(auto& e : pf[i]) {
            lcm[e.first] = max(lcm[e.first], e.second);
        }
    }

    mint ans = 0;
    for(lint i=0; i<n; i++) {
        mint b = 1;
        for(auto& e : lcm) {
            b *= pow(e.first, e.second - pf[i][e.first]);
        }
        ans += b;
    }

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:34: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::map<long long int, long long int> >, std::map<long long int, long long int> >::value_type' {aka 'std::map<long long int, long long int>'} and 'std::map<long int, long int>')
   55 |         pf[i] = prime_factor(a[i]);
      |                                  ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:331:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(const std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  331 |       operator=(const map&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:331:17: note:   no known conversion for argument 1 from 'std::map<long int, long int>' to 'const std::map<long long int, long long int>&'
  331 |       operator=(const map&) = default;
      |                 ^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:335:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(std::map<_Key, _Tp, _Compare, _Alloc>&&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  335 |       operator=(map&&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:335:17: note:   no known conversion for argument 1 from 'std::map<long int, long int>' to 'std::map<long long int, long long int>&&'
  335 |       operator=(map&&) = default;
      |                 ^~~~~
/usr/include/c++/14/bits/stl_map.h:349:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(std::initializer_list<std::pair<const _Key, _Val> >) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  349 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:349:46: note:   no known conversion for argument 1 from 'std::map<long int, long int>' to 'std::initializer_list<std::pair<const long long int, long long int> >'
  349 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~