#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 5;
int a[maxn];
int cnt[maxn];
int vis[maxn];
int main() {
  int n, maxx = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
    maxx = max(maxx, a[i]);
  }
  for (int i = 1; i <= maxx; i++) {
    cnt[i] += cnt[i - 1];
  }
  long long ans = 0;
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    long long sum = 0;
    if (!vis[a[i]]) {
      for (int x = a[i]; x <= maxx; x += a[i]) {
        sum += (long long)(cnt[min(a[i] + x - 1, maxx)] - cnt[x - 1]) * x;
        vis[a[i]] = 1;
      }
      ans = max(ans, sum);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
