Language: C++

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
const int MAX = 510000;
const int 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;
    }
};
template <typename T>
T GCD(T x, T y)
{
    if (x < y)
    {
        const T a = x;
        x = y;
        y = a;
    }
    T b = 100000;
    while (b)
    {
        b = x % y;
        x = y;
        y = b;
    }
    return x;
}
template <typename T>
T lcm(T x, T y)
{
    T g = GCD(x, y);
    return x / g * y;
}
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 n;
    cin >> n;
    vector<i64> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    modcul<i64> tmp(a[0]);
    for (int i = 0; i < n; i++)
    {
        tmp = lcm(tmp, a[i]);
    }
    modcul<i64> ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans.operator+(tmp / a[i]);
    }
    cout << ans.a << endl;
}

Compiler output:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:4:
/usr/include/c++/14/numeric: In instantiation of 'constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn) [with _Mn = modcul<long int>; _Nn = long int; common_type_t<_Mn, _Nn> = modcul<long int>]':
a.cc:133:18:   required from here
  133 |         tmp = lcm(tmp, a[i]);
      |               ~~~^~~~~~~~~~~
/usr/include/c++/14/numeric:190:21: error: static assertion failed: std::lcm arguments must be integers
  190 |       static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
      |                     ^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/numeric:190:21: note: 'std::is_integral_v<modcul<long int> >' evaluates to false
/usr/include/c++/14/numeric:192:28: error: no match for 'operator==' (operand types are 'modcul<long int>' and 'int')
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1033 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'const std::pair<_T1, _T2>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  441 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  486 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1667 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'const std::move_iterator<_IteratorL>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1737 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'const std::move_iterator<_IteratorL>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
In file included from /usr/include/c++/14/bits/char_traits.h:42,
                 from /usr/include/c++/14/string:42,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
  192 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'const std::fpos<_StateT>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
  235 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'const std::allocator<_CharT>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
  629 |     operator==(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
  637 |     operator==(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
  644 |     operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3755 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 3772 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3819 |     operator==(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   mismatched types 'const _CharT*' and 'modcul<long int>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |                     ~~~~~~~^~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
 2558 |     operator==(const tuple<_TElements...>& __t,
      |     ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/numeric:192:28: note:   'modcul<long int>' is not derived from 'const std::tuple<_UTypes ...>'
  192 |       static_assert(_Mn(2) == 2 && _Nn(2) == 2,
      |