#include <bits/stdc++.h>
using namespace std;
int gcd(int m, int n) {
  if ((0 == m) || (0 == n)) return 0;
  while (m != n) {
    if (m > n)
      m = m - n;
    else
      n = n - m;
  }
  return m;
}
int lcm(int m, int n) {
  if ((0 == m) || (0 == n)) return 0;
  return ((m / gcd(m, n)) * n);
}
int lcm_n(vector<int> &numbers) {
  int l;
  l = numbers[0];
  for (int i = 1; i < numbers.size(); i++) {
    l = lcm(l, numbers[i]);
  }
  return l;
}
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int(i) = 0; (i) < (N); (i)++) cin >> a[i];
  int lcm_num = lcm_n(a);
  int ans = 0;
  int temp;
  for (int l = lcm_num; l >= 0; l--) {
    temp = 0;
    for (int(i) = 0; (i) < (N); (i)++) {
      temp += l % a[i];
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
  return 0;
}
