#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (b > 0) {
    int c = a;
    a = b;
    b = c % b;
  }
  return a;
}
long long f(long long m, vector<int> a) {
  long long res = 0;
  for (int i = 0; i < a.size(); i++) res += (m % a[i]);
  return res;
}
int main(void) {
  int n;
  long long sum = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  long long ans = 0;
  for (int m = 0; m < sum; m++) {
    ans = max(ans, f(m, a));
  }
  cout << ans << endl;
  return 0;
}
