#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int x,sum,ans; 
  for(int i=1;i<n;i++){
    if(i==1) x = a[0]/__gcd(a[0],a[1])*a[1];
    x = x/__gcd(x,a[i])*a[i];
  }
  for(int i=1;i<x;i++){
    sum=0;
    for(int j=0;j<n;j++){
      sum+=(i%a[j]);
    }
    ans=max(ans,sum);
  }

  cout << ans << endl;
  return 0;
}