#include <bits/stdc++.h>
using namespace std;
const int MX = 200005;
int n;
long long m, Arr[MX], tmp[MX];
void solve(){
long long mx = 0;
for(int i = 0; i<n; i++){
int num = Arr[i];
long long pre = tmp[num];
if(i != 0) pre -= tmp[Arr[i-1]];
long long ans = pre * (long long) num;
mx = max(ans, mx);
for(int j = 2 * num; j < MX; j += num){
long long diff = tmp[j] - tmp[j - num];
if(diff > 0){
int lo = lower_bound(Arr, Arr + n, j) - Arr;
int hi = upper_bound(Arr, Arr + n, j) - Arr;
ans += (long long)(hi - lo) * (long long) j;
ans += (diff - (long long)(hi - lo)) * (long long)(j - num);
}
}
mx = max(mx, ans);
}
printf("%lld\n", mx);
}
int main() {
scanf("%d", &n);
m = 0;
for(int i = 0; i<n; i++){
scanf("%lld", &Arr[i]);
m = max(m, Arr[i]);
tmp[Arr[i]]++;
}
sort(Arr, Arr + n);
for(int i = 1; i< MX; i++){
tmp[i] += tmp[i-1];
}
solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTVggPSAyMDAwMDU7CmludCBuOwpsb25nIGxvbmcgbSwgQXJyW01YXSwgdG1wW01YXTsKCnZvaWQgc29sdmUoKXsKCWxvbmcgbG9uZyBteCA9IDA7Cglmb3IoaW50IGkgPSAwOyBpPG47IGkrKyl7CgkJaW50IG51bSA9IEFycltpXTsKCQlsb25nIGxvbmcgcHJlID0gdG1wW251bV07CgkJaWYoaSAhPSAwKSBwcmUgLT0gdG1wW0FycltpLTFdXTsKCQlsb25nIGxvbmcgYW5zID0gcHJlICogKGxvbmcgbG9uZykgbnVtOwoJCW14ID0gbWF4KGFucywgbXgpOwoJCQoJCWZvcihpbnQgaiA9IDIgKiBudW07IGogPCBNWDsgaiArPSBudW0pewoJCQlsb25nIGxvbmcgZGlmZiA9IHRtcFtqXSAtIHRtcFtqIC0gbnVtXTsKCQkJaWYoZGlmZiA+IDApewoJCQkJaW50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