#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 20;
long long int book[2 * maxn];
bool has[2 * maxn];
void work() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int a;
    scanf("%d", &a);
    book[a]++;
    has[a] = true;
  }
  for (int i = 1; i <= 2 * maxn - 20; ++i) {
    book[i] += book[i - 1];
  }
  long long int ans = -(0x3f3f3f3f);
  for (int i = 1; i <= maxn - 20; ++i) {
    if (!has[i]) continue;
    long long int t = 0;
    for (int j = i; j <= maxn - 20; j += i) {
      t += (book[j + i - 1] - book[j - 1]) * j;
    }
    ans = max(ans, t);
  }
  cout << ans << endl;
}
int main() {
  work();
  return 0;
}
