Language: C++


template<Int Mod = 1000000007> class modint{
public:
	Int val;
	constexpr modint(const Int x = 0) : val(x % Mod) {if(val < 0) val += Mod;}
	constexpr modint operator+(const modint rhs) const {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const {
		return modint(*this) /= rhs;
	}
	constexpr modint operator-() const {
		return modint(Mod - val);
	}
	constexpr modint &operator+=(const modint rhs){
		val += rhs.val;
		if(val >= Mod) val -= Mod;
		return *this;
	}
	constexpr modint &operator-=(const modint rhs){
		if(val < rhs.val) val += Mod;
		val -= rhs.val;
		return *this;
	}
	constexpr modint &operator*=(const modint rhs){
		val *= rhs.val;
		val %= Mod;
		return *this;
	}
	constexpr modint &operator/=(const modint rhs){
		return *this *= inv(rhs);
	}
	constexpr modint &operator++(){
		++val;
		if(val == Mod) val = 0;
		return *this;
	}
	constexpr modint &operator--(){
		--val;
		if(val == -1) val = Mod - 1;
		return *this;
	}
	constexpr modint operator<<(const Int rhs) const {
		return modint(*this) << rhs;
	}
	constexpr modint operator>>(const Int rhs) const {
		return modint(*this) >> rhs;
	}
	constexpr modint &operator<<=(const Int rhs){
		val <<= rhs;
		val %= Mod;
		return *this;
	}
	constexpr modint &operator>>=(const Int rhs){
		val >>= rhs;
		val %= Mod;
		return *this;
	}
	constexpr bool operator==(const modint rhs) const {
		return val == rhs.val;
	}
	constexpr bool operator!=(const modint rhs) const {
		return val != rhs.val;
	}
	constexpr bool operator<(const modint rhs) const {
		return val < rhs.val;
	}
	constexpr bool operator>(const modint rhs) const {
		return val > rhs.val;
	}
	constexpr bool operator<=(const modint rhs) const {
		return val <= rhs.val;
	}
	constexpr bool operator>=(const modint rhs) const {
		return val >= rhs.val;
	}
	friend ostream& operator<<(ostream& os, const modint<Mod>& m){
		return os << m.val;
	}
	friend istream& operator>>(istream& is, modint<Mod>& m){
		return is >> m.val;
	}
	static constexpr modint inv(modint m){
		Int a = m.val, b = Mod, u = 1, v = 0;
		while(b){
			Int t = a / b;
			a -= t * b;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		u %= Mod;
		if(u < 0) u += Mod;
		return modint(u);
	}
	constexpr operator Int() const {
		return val;
	}
};
using mint = modint<>;
vector<Int> p;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	for(Int i=2; i<=1000; ++i){
		bool f = true;
		for(auto j:p)
			if(j % i == 0){
				f = false;
				break;
			}
		if(f) p.push_back(i);
	}
	Int n; cin >> n;
	vector<Int> a(n);
	for(auto &i:a) cin >> i;
	vector<Int> l(p.size());
	set<Int> st;
	for(auto i:a){
		Int u = i;
		vector<Int> t(p.size());
		for(size_t j=0; j<p.size(); ++j){
			while(u % p[j] == 0){
				++t[j];
				u /= p[j];
			}
		}
		st.insert(u);
		for(size_t j=0; j<p.size(); ++j)
			l[j] = max(l[j], t[j]);
	}
	mint m = 1;
	for(size_t i=0; i<l.size(); ++i)
		for(Int j=0; j<l[i]; ++j)
			m *= mint(p[i]);
	for(auto ite=st.begin(); ite!=st.end(); ++ite)
		m *= mint(*ite);
	mint ans = 0;
	for(Int i=0; i<n; ++i)
		ans += m / mint(a[i]);
	cout << ans << "\n";
}

Compiler output:
a.cc:2:10: error: 'Int' has not been declared
    2 | template<Int Mod = 1000000007> class modint{
      |          ^~~
a.cc:4:9: error: 'Int' does not name a type; did you mean 'int'?
    4 |         Int val;
      |         ^~~
      |         int
a.cc:5:32: error: 'Int' does not name a type; did you mean 'int'?
    5 |         constexpr modint(const Int x = 0) : val(x % Mod) {if(val < 0) val += Mod;}
      |                                ^~~
      |                                int
a.cc:49:43: error: 'Int' does not name a type; did you mean 'int'?
   49 |         constexpr modint operator<<(const Int rhs) const {
      |                                           ^~~
      |                                           int
a.cc:52:43: error: 'Int' does not name a type; did you mean 'int'?
   52 |         constexpr modint operator>>(const Int rhs) const {
      |                                           ^~~
      |                                           int
a.cc:55:45: error: 'Int' does not name a type; did you mean 'int'?
   55 |         constexpr modint &operator<<=(const Int rhs){
      |                                             ^~~
      |                                             int
a.cc:60:45: error: 'Int' does not name a type; did you mean 'int'?
   60 |         constexpr modint &operator>>=(const Int rhs){
      |                                             ^~~
      |                                             int
a.cc:83:16: error: 'ostream' does not name a type
   83 |         friend ostream& operator<<(ostream& os, const modint<Mod>& m){
      |                ^~~~~~~
a.cc:86:16: error: 'istream' does not name a type
   86 |         friend istream& operator>>(istream& is, modint<Mod>& m){
      |                ^~~~~~~
a.cc:102:28: error: expected type-specifier before 'Int'
  102 |         constexpr operator Int() const {
      |                            ^~~
a.cc:106:21: error: template argument 1 is invalid
  106 | using mint = modint<>;
      |                     ^
a.cc:107:1: error: 'vector' does not name a type
  107 | vector<Int> p;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:110:9: error: 'cin' was not declared in this scope
  110 |         cin.tie(0);
      |         ^~~
a.cc:111:9: error: 'ios' has not been declared
  111 |         ios::sync_with_stdio(false);
      |         ^~~
a.cc:112:13: error: 'Int' was not declared in this scope; did you mean 'int'?
  112 |         for(Int i=2; i<=1000; ++i){
      |             ^~~
      |             int
a.cc:112:22: error: 'i' was not declared in this scope
  112 |         for(Int i=2; i<=1000; ++i){
      |                      ^
a.cc:114:28: error: 'p' was not declared in this scope
  114 |                 for(auto j:p)
      |                            ^
a.cc:119:23: error: 'p' was not declared in this scope
  119 |                 if(f) p.push_back(i);
      |                       ^
a.cc:121:9: error: 'Int' was not declared in this scope; did you mean 'int'?
  121 |         Int n; cin >> n;
      |         ^~~
      |         int
a.cc:121:23: error: 'n' was not declared in this scope
  121 |         Int n; cin >> n;
      |                       ^
a.cc:122:9: error: 'vector' was not declared in this scope
  122 |         vector<Int> a(n);
      |         ^~~~~~
a.cc:122:21: error: 'a' was not declared in this scope
  122 |         vector<Int> a(n);
      |                     ^
a.cc:124:23: error: 'p' was not declared in this scope
  124 |         vector<Int> l(p.size());
      |                       ^
a.cc:124:21: error: 'l' was not declared in this scope
  124 |         vector<Int> l(p.size());
      |                     ^
a.cc:125:9: error: 'set' was not declared in this scope
  125 |         set<Int> st;
      |         ^~~
a.cc:125:18: error: 'st' was not declared in this scope; did you mean 'std'?
  125 |         set<Int> st;
      |                  ^~
      |                  std
a.cc:127:20: error: expected ';' before 'u'
  127 |                 Int u = i;
      |                    ^~
      |                    ;
a.cc:128:29: error: 't' was not declared in this scope
  128 |                 vector<Int> t(p.size());
      |                             ^
a.cc:129:21: error: 'size_t' was not declared in this scope
  129 |                 for(size_t j=0; j<p.size(); ++j){
      |                     ^~~~~~
a.cc:1:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | 
a.cc:129:33: error: 'j' was not declared in this scope
  129 |                 for(size_t j=0; j<p.size(); ++j){
      |                                 ^
a.cc:130:31: error: 'u' was not declared in this scope
  130 |                         while(u % p[j] == 0){
      |                               ^
a.cc:135:27: error: 'u' was not declared in this scope
  135 |                 st.insert(u);
      |                           ^
a.cc:136:21: error: 'size_t' was not declared in this scope
  136 |                 for(size_t j=0; j<p.size(); ++j)
      |                     ^~~~~~
a.cc:136:21: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
a.cc:136:33: error: 'j' was not declared in this scope
  136 |                 for(size_t j=0; j<p.size(); ++j)
      |                                 ^
a.cc:137:32: error: 'max' was not declared in this scope
  137 |                         l[j] = max(l[j], t[j]);
      |                                ^~~
a.cc:139:9: error: 'mint' was not declared in this scope; did you mean 'int'?
  139 |         mint m = 1;
      |         ^~~~
      |         int
a.cc:140:13: error: 'size_t' was not declared in this scope
  140 |         for(size_t i=0; i<l.size(); ++i)
      |             ^~~~~~
a.cc:140:13: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
a.cc:140:25: error: 'i' was not declared in this scope
  140 |         for(size_t i=0; i<l.size(); ++i)
      |                         ^
a.cc:141:24: error: expected ';' before 'j'
  141 |                 for(Int j=0; j<l[i]; ++j)
      |                        ^~
      |                        ;
a.cc:141:30: error: 'j' was not declared in this scope
  141 |                 for(Int j=0; j<l[i]; ++j)
      |                              ^
a.cc:142:25: error: 'm' was not declared in this scope
  142 |                         m *= mint(p[i]);
      |                         ^
a.cc:144:17: error: 'm' was not declared in this scope
  144 |                 m *= mint(*ite);
      |                 ^
a.cc:145:13: error: expected ';' before 'ans'
  145 |         mint ans = 0;
      |             ^~~~
      |             ;
a.cc:146:16: error: expected ';' before 'i'
  146 |         for(Int i=0; i<n; ++i)
      |                ^~
      |                ;
a.cc:146:22: error: 'i' was not declared in this scope
  146 |         for(Int i=0; i<n; ++i)
      |                      ^
a.cc:147:17: error: 'ans' was not declared in this scope
  147 |                 ans += m / mint(a[i]);
      |                 ^~~
a.cc:147:24: error: 'm' was not declared in this scope
  147 |                 ans += m / mint(a[i]);
      |                        ^
a.cc:148:9: error: 'cout' was not declared in this scope
  148 |         cout << ans << "\n";
      |         ^~~~
a.cc:148:17: error: 'ans' was not declared in this scope
  148 |         cout << ans << "\n";
      |                 ^~~