#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 228;
const long long INFLL = 1e18;
const long long MOD = 1e9 + 7;
const long double eps = 1e-6;
const long double eps2 = 1e-9;
const long long MOD2 = 998244353;
const long long dosz = 5e5;
const long long SZ = (1 << 18);
const long double PI = atan2l(0, -1);
void fast_io() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
long long f(vector<long long> nums, long long a) {
  long long ans = 0;
  for (long long i : nums) ans += a % i;
  return ans;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> nums(n);
  for (long long &i : nums) cin >> i;
  long long cur_ans = 0;
  for (long long i = 1; i <= 1e5; i++) cur_ans = max(cur_ans, f(nums, i));
  cout << cur_ans << endl;
}
signed main() {
  fast_io();
  srand(time(NULL));
  cout << fixed << setprecision(12);
  long long q = 1;
  while (q--) solve();
}
