#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
int b[10];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    a.push_back(temp);
  }
  sort(a.begin(), a.end());
  int mx = a[n - 1];
  int res = 0;
  for (int m = mx; m < mx * 1000; m++) {
    int ans = 0;
    for (auto u : a) {
      ans += m % u;
    }
    res = max(ans, res);
  }
  cout << res << endl;
}
