#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e3 + 9, MAXA = 1e6 + 6, SQRT = 447;
int n, ans;
int Arr[MAXN];
int f(int m) {
  int res = 0;
  for (int i = 0; i < n; i++) res += m % Arr[i];
  ans = max(ans, res);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &Arr[i]);
  for (int i = 0; i < 2e5; i++) f(i);
  printf("%d", ans);
}
