Language: C++

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"

/* MOD */
ll MOD = 1000000000LL + 7LL;
class Mint {
public:
  ll x;
  Mint() : x(0) {}
  Mint(const int x) {
    if (x < MOD && x >= 0) this->x = x;
    else this->x = (MOD + x % MOD) % MOD;
  }
  Mint(const ll x) {
    if (x < MOD && x >= 0) this->x = x;
    else this->x = (MOD + x % MOD) % MOD;
  }
  Mint(const Mint& c) {
    this->x = c.x;
  }
  Mint& operator=(const int c) {
    if (c < MOD && c >= 0) this->x = c;
    else this->x = (MOD + c % MOD) % MOD;
    return *this;
  }
  Mint& operator=(const ll c) {
    if (c < MOD && c >= 0) this->x = c;
    else this->x = (MOD + c % MOD) % MOD;
    return *this;
  }
  Mint& operator=(const Mint c) {
    this->x = c.x;
    return *this;
  }
  bool operator==(const Mint &b) {
    return x == b.x;
  }
  bool operator!=(const Mint &b) {
    return !(x == b.x);
  }
  bool operator<(const Mint &b) {
    return x < b.x;
  }
  bool operator>(const Mint &b) {
    return x > b.x;
  }
};
ostream &operator<<(ostream& out, const Mint &mint) {
  out << mint.x;
  return out;
}
istream &operator>>(istream& in, const Mint &mint) {
  in >> mint.x;
  return in;
}
inline Mint add(const Mint a, const Mint b) {
  const ll x = (a.x + b.x) % MOD;
  return Mint(x);
}
inline Mint mul(const Mint a, const Mint b) {
  ll x = (a.x * b.x) % MOD;
  return Mint(x);
}
template <typename T>
Mint ModPow(Mint a, T b) {
  assert(b >= 0);
  Mint res = 1;
  while (b)
  {
    if (b & 1)
      res = mul(res, a);
    b >>= 1;
    a = mul(a, a);
  }
  return res;
}
inline Mint ModInverse(const Mint x) {
  ll a = x.x, b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    swap(a -= t * b, b);
    swap(u -= t * v, v);
  }
  Mint res(u);
  return res;
}
inline Mint operator-(const Mint x) {
  return Mint(-x.x);
}
inline Mint operator+(const Mint a, const Mint b) {
  return add(a, b);
}
inline Mint operator*(const Mint a, const Mint b) {
  return mul(a, b);
}
inline Mint operator-(const Mint a, const Mint b) {
  return add(a, -b);
}
template<typename T>
inline Mint operator+(const Mint a, const T b) {
  return add(a, Mint(b));
}
template<typename T>
inline Mint operator*(const Mint a, const T b) {
  return mul(a, Mint(b));
}
template<typename T>
inline Mint operator-(const Mint a, const T b) {
  return add(a, Mint(-b));
}
template<typename T>
inline Mint operator/(const Mint a, const T b) {
  return mul(a, ModInverse(Mint(b)));
}
template<typename T>
inline Mint operator^(const Mint a, const T b) {
  return ModPow(a, b);
}
template<typename T>
inline Mint operator+=(Mint& a, const T b) {
  a = a + b;
  return a;
}
template<typename T>
inline Mint operator-=(Mint& a, const T b) {
  a = a - b;
  return a;
}
template<typename T>
inline Mint operator*=(Mint& a, const T b) {
  a = a * b;
  return a;
}
template<typename T>
inline Mint operator/=(Mint& a, const T b) {
  a = a / b;
  return a;
}
template <typename T>
T EulerTotient(T a)
{
  vector<pair<int, int>> v;
  for (T i = 2; i * i <= a; i++)
  {
    int cnt = 0;
    while (a % i == 0)
    {
      cnt++;
      a /= i;
    }
    if (cnt != 0)
      v.emplace_back(i, cnt);
  }
  if (a != 1)
    v.emplace_back(a, 1);
  //showV(v, (int) v.size());
  T res = 1;
  for (int i = 0; i < (int)v.size(); i++)
  {
    if (v[i].se == 1)
    {
      res *= v[i].fi - 1;
    }
    else
    {
      res *= Pow(v[i].fi, v[i].se) - Pow(v[i].fi, v[i].se - 1);
    }
  }
  return res;
}
template<typename T, typename S>
Mint comb(T a, S b)
{
  chmin(b, a - b);
  Mint res = 1LL, now = a;
  for (ll i = 1; i <= b; i++)
  {
    res *= now;
    res /= i;
    now -= 1;
  }
  return res;
}

int n;
int a[10001];
vector<pair<int, int> > v[10001];
map<int, int> _max;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    int now = a[i];
    for (int j = 2; j * j <= now; j++) {
      int cnt = 0;
      while (now % j == 0) {
        cnt++;
        now /= j;
      }
      if (cnt > 0) v[i].pb(mp(j, cnt));
    }
    if (now > 1) {
      v[i].pb(mp(now, 1));
    }
    for (int j = 0; j < (int)v[i].size(); j++) _max[v[i][j].fi] = max(_max[v[i][j].fi], v[i][j].se);
  }
  Mint gcd = 1;
  for (auto ite = _max.begin(); ite != _max.end(); ite++) {
    gcd = gcd * ModPow(ite->fi, ite->se);
  }
  Mint ans = 0;
  for (int i = 0; i < n; i++) {
    Mint now = gcd;
    for (int j = 0; j < (int)v[i].size(); j++) {
      now = now / ModPow(v[i][j].fi, v[i][j].se);
    }
    ans = ans + now;
  }
  cout << ans << endl;
}

Compiler output:
a.cc:12:1: error: 'll' does not name a type
   12 | ll MOD = 1000000000LL + 7LL;
      | ^~
a.cc:15:3: error: 'll' does not name a type
   15 |   ll x;
      |   ^~
a.cc:21:14: error: 'll' does not name a type
   21 |   Mint(const ll x) {
      |              ^~
a.cc:21:3: error: 'Mint::Mint(int)' cannot be overloaded with 'Mint::Mint(int)'
   21 |   Mint(const ll x) {
      |   ^~~~
a.cc:17:3: note: previous declaration 'Mint::Mint(int)'
   17 |   Mint(const int x) {
      |   ^~~~
a.cc:33:25: error: 'll' does not name a type
   33 |   Mint& operator=(const ll c) {
      |                         ^~
a.cc:33:9: error: 'Mint& Mint::operator=(int)' cannot be overloaded with 'Mint& Mint::operator=(int)'
   33 |   Mint& operator=(const ll c) {
      |         ^~~~~~~~
a.cc:28:9: note: previous declaration 'Mint& Mint::operator=(int)'
   28 |   Mint& operator=(const int c) {
      |         ^~~~~~~~
a.cc: In constructor 'Mint::Mint()':
a.cc:16:12: error: class 'Mint' does not have any field named 'x'
   16 |   Mint() : x(0) {}
      |            ^
a.cc: In constructor 'Mint::Mint(int)':
a.cc:18:13: error: 'MOD' was not declared in this scope
   18 |     if (x < MOD && x >= 0) this->x = x;
      |             ^~~
a.cc:18:34: error: 'class Mint' has no member named 'x'
   18 |     if (x < MOD && x >= 0) this->x = x;
      |                                  ^
a.cc:19:16: error: 'class Mint' has no member named 'x'
   19 |     else this->x = (MOD + x % MOD) % MOD;
      |                ^
a.cc: In constructor 'Mint::Mint(int)':
a.cc:22:13: error: 'MOD' was not declared in this scope
   22 |     if (x < MOD && x >= 0) this->x = x;
      |             ^~~
a.cc:22:34: error: 'class Mint' has no member named 'x'
   22 |     if (x < MOD && x >= 0) this->x = x;
      |                                  ^
a.cc:23:16: error: 'class Mint' has no member named 'x'
   23 |     else this->x = (MOD + x % MOD) % MOD;
      |                ^
a.cc: In copy constructor 'Mint::Mint(const Mint&)':
a.cc:26:11: error: 'class Mint' has no member named 'x'
   26 |     this->x = c.x;
      |           ^
a.cc:26:17: error: 'const class Mint' has no member named 'x'
   26 |     this->x = c.x;
      |                 ^
a.cc: In member function 'Mint& Mint::operator=(int)':
a.cc:29:13: error: 'MOD' was not declared in this scope
   29 |     if (c < MOD && c >= 0) this->x = c;
      |             ^~~
a.cc:29:34: error: 'class Mint' has no member named 'x'
   29 |     if (c < MOD && c >= 0) this->x = c;
      |                                  ^
a.cc:30:16: error: 'class Mint' has no member named 'x'
   30 |     else this->x = (MOD + c % MOD) % MOD;
      |                ^
a.cc: In member function 'Mint& Mint::operator=(int)':
a.cc:34:13: error: 'MOD' was not declared in this scope
   34 |     if (c < MOD && c >= 0) this->x = c;
      |             ^~~
a.cc:34:34: error: 'class Mint' has no member named 'x'
   34 |     if (c < MOD && c >= 0) this->x = c;
      |                                  ^
a.cc:35:16: error: 'class Mint' has no member named 'x'
   35 |     else this->x = (MOD + c % MOD) % MOD;
      |                ^
a.cc: In member function 'Mint& Mint::operator=(Mint)':
a.cc:39:11: error: 'class Mint' has no member named 'x'
   39 |     this->x = c.x;
      |           ^
a.cc:39:17: error: 'const class Mint' has no member named 'x'
   39 |     this->x = c.x;
      |                 ^
a.cc: In member function 'bool Mint::operator==(const Mint&)':
a.cc:43:12: error: 'x' was not declared in this scope
   43 |     return x == b.x;
      |            ^
a.cc:43:19: error: 'const class Mint' has no member named 'x'
   43 |     return x == b.x;
      |                   ^
a.cc: In member function 'bool Mint::operator!=(const Mint&)':
a.cc:46:14: error: 'x' was not declared in this scope
   46 |     return !(x == b.x);
      |              ^
a.cc:46:21: error: 'const class Mint' has no member named 'x'
   46 |     return !(x == b.x);
      |                     ^
a.cc: In member function 'bool Mint::operator<(const Mint&)':
a.cc:49:12: error: 'x' was not declared in this scope
   49 |     return x < b.x;
      |            ^
a.cc:49:18: error: 'const class Mint' has no member named 'x'
   49 |     return x < b.x;
      |                  ^
a.cc: In member function 'bool Mint::operator>(const Mint&)':
a.cc:52:12: error: 'x' was not declared in this scope
   52 |     return x > b.x;
      |            ^
a.cc:52:18: error: 'const class Mint' has no member named 'x'
   52 |     return x > b.x;
      |                  ^
a.cc: In function 'std::ostream& operator<<(std::ostream&, const Mint&)':
a.cc:56:15: error: 'const class Mint' has no member named 'x'
   56 |   out << mint.x;
      |               ^
a.cc: In function 'std::istream& operator>>(std::istream&, const Mint&)':
a.cc:60:14: error: 'const class Mint' has no member named 'x'
   60 |   in >> mint.x;
      |              ^
a.cc: In function 'Mint add(Mint, Mint)':
a.cc:64:9: error: 'll' does not name a type
   64 |   const ll x = (a.x + b.x) % MOD;
      |         ^~
a.cc:65:15: error: 'x' was not declared in this scope
   65 |   return Mint(x);
      |               ^
a.cc: In function 'Mint mul(Mint, Mint)':
a.cc:68:3: error: 'll' was not declared in this scope
   68 |   ll x = (a.x * b.x) % MOD;
      |   ^~
a.cc:69:15: error: 'x' was not declared in this scope
   69 |   return Mint(x);
      |               ^
a.cc: In function 'Mint ModInverse(Mint)':
a.cc:85:3: error: 'll' was not declared in this scope
   85 |   ll a = x.x, b = MOD, u = 1, v = 0;
      |   ^~
a.cc:86:10: error: 'b' was not declared in this scope
   86 |   while (b) {
      |          ^
a.cc:87:7: error: expected ';' before 't'
   87 |     ll t = a / b;
      |       ^~
      |       ;
a.cc:88:10: error: 'a' was not declared in this scope
   88 |     swap(a -= t * b, b);
      |          ^
a.cc:88:15: error: 't' was not declared in this scope
   88 |     swap(a -= t * b, b);
      |               ^
a.cc:89:10: error: 'u' was not declared in this scope
   89 |     swap(u -= t * v, v);
      |          ^
a.cc:89:19: error: 'v' was not declared in this scope
   89 |     swap(u -= t * v, v);
      |                   ^
a.cc:91:12: error: 'u' was not declared in this scope
   91 |   Mint res(u);
      |            ^
a.cc: In function 'Mint operator-(Mint)':
a.cc:95:18: error: 'const class Mint' has no member named 'x'
   95 |   return Mint(-x.x);
      |                  ^
a.cc: In function 'T EulerTotient(T)':
a.cc:173:14: error: there are no arguments to 'Pow' that depend on a template parameter, so a declaration of 'Pow' must be available [-fpermissive]
  173 |       res *= Pow(v[i].fi, v[i].se) - Pow(v[i].fi, v[i].se - 1);
      |              ^~~
a.cc:173:14: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc:173:38: error: there are no arguments to 'Pow' that depend on a template parameter, so a declaration of 'Pow' must be available [-fpermissive]
  173 |       res *= Pow(v[i].fi, v[i].se) - Pow(v[i].fi, v[i].se - 1);
      |                                      ^~~
a.cc: In function 'Mint comb(T, S)':
a.cc:183:8: error: 'll' was not declared in this scope
  183 |   for (ll i = 1; i <= b; i++)
      |        ^~
a.cc:183:18: error: 'i' was not declared in this scope
  183 |   for (ll i = 1; i <= b; i++)
      |                  ^