#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, N, lcm_num;
  int ans = 0;
  int temp_ans = 0;
  int a[3200];
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> a[i];
  }
  lcm_num = 1000000;
  while (lcm_num != 0) {
    for (i = 0; i < N; i++) {
      temp_ans = temp_ans + lcm_num % a[i];
    }
    if (temp_ans > ans) ans = temp_ans;
    temp_ans = 0;
    lcm_num--;
  }
  cout << ans << endl;
}
