#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  struct Node {
    long long index;
    long long cnt;
  };
  void solve(istream& cin = std::cin, ostream& cout = std::cout) {
    int n;
    cin >> n;
    vector<long long> arr(n, 0);
    long long maxvalue = 0;
    long long minvalue = LLONG_MAX;
    for (int arr_i = 0; arr_i < n; arr_i++) {
      cin >> arr[arr_i];
      ((maxvalue) = ((maxvalue) > (arr[arr_i]) ? (maxvalue) : (arr[arr_i])));
      ((minvalue) = ((minvalue) < (arr[arr_i]) ? (minvalue) : (arr[arr_i])));
    }
    vector<long long> cnt(2 * maxvalue + 1, 0);
    for (int i = 0; i < n; i++) {
      cnt[arr[i]]++;
    }
    for (int i = 0; i < cnt.size() - 1; i++) {
      cnt[i + 1] += cnt[i];
    }
    long long ans = 0;
    for (long long i = minvalue; i <= maxvalue; i++) {
      if (cnt[i] - cnt[i - 1] == 0) continue;
      long long tmp = 0;
      for (int j = 2 * i; j < cnt.size(); j += i) {
        tmp += (cnt[j - 1] - cnt[j - i]) * (j - i) + (cnt[j] - cnt[j - 1]) * j;
        if (j > maxvalue) break;
      }
      tmp += i * (cnt[i] - cnt[i - 1]);
      ((ans) = ((ans) > (tmp) ? (ans) : (tmp)));
    }
    cout << ans << endl;
  }
};
int main() {
  Solution s;
  s.solve();
  return 0;
}
