#include <bits/stdc++.h>
using namespace std;
const int maxN = 200000;
int T[maxN + 1], biggest_ind_of_lower_value[maxN * 2 + 1];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", T + i);
  sort(T + 1, T + n + 1);
  for (int i = 1; i < n; i++)
    for (int j = T[i] + 1; j <= T[i + 1]; j++)
      biggest_ind_of_lower_value[j] = i;
  for (int i = T[n] + 1; i <= T[n] * 2; i++) biggest_ind_of_lower_value[i] = n;
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    if (i > 0 and T[i - 1] == T[i]) continue;
    long long res_temp = 0;
    for (int j = T[i]; j <= T[n]; j += T[i])
      res_temp += ((long long)j * (biggest_ind_of_lower_value[j + T[i]] -
                                   biggest_ind_of_lower_value[j]));
    res = max(res, res_temp);
  }
  printf("%I64d\n", res);
  return 0;
}
