#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 200001;
int dp[SIZE];
long long an;
int main() {
  int(n);
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    int(x);
    scanf("%d", &x);
    dp[x]++;
  }
  for (int i = (1); i < (SIZE); ++i) dp[i] += dp[i - 1];
  for (int i = (1); i < (SIZE); ++i) {
    if (dp[i] != dp[i - 1]) {
      long long v = 0;
      for (int j = i; j < SIZE; j += i) {
        v += j * (long long)(dp[min(SIZE - 1, j + i - 1)] - dp[j - 1]);
      }
      an = max(an, v);
    }
  }
  cout << an << endl;
  return 0;
}
