#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
bool st[200007];
vector<long long> values;
int main() {
  int n, idx, last;
  long long ans = 0, aux, v, actual;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &v);
    values.emplace_back(v);
    ans = max(ans, (long long)v);
  }
  sort(values.begin(), values.end());
  for (int i = 0; i < n; i++) {
    if (st[values[i]]) continue;
    aux = values[i], last = i + 1, actual = values[i];
    while (last < n) {
      st[aux] = true;
      idx = lower_bound(values.begin(), values.end(), aux + values[i]) -
            values.begin();
      actual += aux * ((long long)idx - last);
      aux += values[i];
      last = idx;
    }
    ans = max(ans, actual);
  }
  printf("%lld\n", ans);
  return 0;
}
