#include using namespace std; // #define LOCAL // 提出時はコメントアウト #define DEBUG_ typedef long long ll; const double EPS = 1e-9; const ll INF = ((1LL<<62)-(1LL<<31)); typedef vector vecl; typedef pair pairl; template using mapv = map>; #define ALL(v) v.begin(), v.end() #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i, n) REP(i, 0, n) #define contains(S,x) find(ALL(S),x) != S.end() ll llceil(ll a,ll b) { return (a+b-1)/b; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template vector> genarr(ll n, ll m, T init) { return vector>(n,vector(m,init)); } ///// DEBUG #define DUMPOUT cerr #define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++) templateistream&operator>>(istream&is,vector&vec){for(T&x:vec)is>>x;return is;} templateostream&operator<<(ostream&os,pair&pair_var){os<<"("<ostream&operator<<(ostream&os,const vector&vec){os<<"{";for(int i=0;iostream&operator<<(ostream&os,map&map_var){os<<"{";repi(itr,map_var){os<<*itr;itr++;if(itr!=map_var.end())os<<", ";itr--;} os<<"}";return os;} templateostream&operator<<(ostream&os,set&set_var){os<<"{";repi(itr,set_var){os<<*itr;itr++;if(itr!=set_var.end())os<<", ";itr--;} os<<"}";return os;} void dump_func(){DUMPOUT<void dump_func(Head&&head,Tail&&...tail){DUMPOUT<0){DUMPOUT<<", ";} dump_func(std::move(tail)...);} #ifndef LOCAL #undef DEBUG_ #endif #ifdef DEBUG_ #define DEB #define dump(...) \ DUMPOUT << " " << string(#__VA_ARGS__) << ": " \ << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" \ << endl \ << " ", \ dump_func(__VA_ARGS__) #else #define DEB if (false) #define dump(...) #endif ////////// template class Accumulation { public: vector v; Accumulation(const vector &X,ll N, ll init_val=0) { v.assign(N+1,0); v[0] = init_val; rep(i,N) { v[i+1] = v[i] + X[i]; } } T query(ll l,ll r) { // [0,r] return v[r+1] - v[l]; } }; int main() { #ifdef LOCAL ifstream in("../../Atcoder/input.txt"); cin.rdbuf(in.rdbuf()); #endif ll N; cin>>N; vecl A(N); ll sum = 0; ll max = 0; rep(i,N) { cin>>A[i]; sum += A[i]; chmax(max,A[i]); } vecl distribution(max+10,0LL); rep(i,N) { ll b = A[i]; while (b < max+10) { distribution[b]+=A[i]; b += A[i]; } } Accumulation db_acc(distribution,max+20); ll ans = 0; rep(i,N) { ans += sum; ans -= db_acc.query(0,A[i]); } cout << ans << endl; return 0; }