#include using namespace std; constexpr int mod = 1000000007; template vector>> quotient_range(T N) { vector>>ans; T i = 1; for(; i*i <= N; i++) { ans.push_back({N/i,{i,i}}); } for(; i >= 1; i--) { T l = N/(i+1)+1; T r = N/i; if(l <= r && ans.back().second.first < l) { ans.push_back({N/l,{l,r}}); } } return ans; } int main() { int N; cin >> N; vectorA(N); vectorsum(200200); for(int i = 0; i < N; i++) { cin >> A[i]; vector>> a = quotient_range(A[i]); for(int j = 0; j < a.size(); j++) { sum[a[j].second.first] += a[j].first; sum[a[j].second.second+1] -= a[j].first; } } for(int i = 0; i <= 200000; i++) { sum[i+1] += sum[i]; } sort(A.begin(),A.end()); long long sum2 = 0; long long ans = 0; for(int i = N-1; i >= 0; i--) { sum2 += A[i]; ans += mod-(sum2-1ll*A[i]*sum[A[i]])%mod; ans %= mod; ans += 1ll*A[i]*(N-i-1)%mod; ans %= mod; } cout << ans << endl; }