#include <bits/stdc++.h>
long long a[114514];
using namespace std;
signed main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long seki = 1;
  for (long long i = 0; i < n; i++) {
    seki = seki * a[i];
  }
  long long ans = -810;
  long long sum = 0;
  for (long long i = 0; i < seki; i++) {
    sum = 0;
    for (long long j = 0; j < n; j++) {
      sum += i % a[j];
    }
    if (sum > ans) {
      ans = sum;
    }
  }
  cout << ans << endl;
}
