#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
const int MAXN = 1e4 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;
int dx[] = {0, -1, 0, 1};
int dy[] = {1, 0, -1, 0};
bool prime[200100];
int n;
int a[200100];
int mark[200100];
long long sum[200100];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[a[i]]++;
  }
  for (int i = 1; i <= 200000; i++) sum[i] += sum[i - 1];
  sort(a + 1, a + n + 1);
  long long res = -1;
  for (int i = 1; i <= n; i++)
    if (!mark[a[i]]) {
      int l = a[i];
      mark[l] = 1;
      long long total = 0;
      while (l <= a[n]) {
        int r = min(a[n], l + a[i] - 1);
        total += (sum[r] - sum[l - 1]) * (long long)l;
        l += a[i];
      }
      res = max(res, total);
    }
  cout << res;
  return 0;
}
