#include <bits/stdc++.h>
using namespace std;
int gcm(int a, int b) {
  int result = a;
  int k = 0;
  int n = b;
  do {
    k = result % n;
    result = n;
    n = k;
  } while (k != 0);
  return result;
}
int lcm(int a, int b) {
  int g;
  g = gcm(a, b);
  return a * b / g;
}
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;
}
