#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pii = pair<int,int>;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  vector<ll>a(n);
  for (auto& x : a) cin >> x;
  vector<ll> pr(n+1);
  for (int i = 1; i <= n; i++)
    pr[i] = pr[i-1]+a[i-1];
  ll mx =0;
  ll sum = 0;
  for (int k = 0; k < n; k++) {
    mx = max(mx,a[k]);
    cout << (k+1)*mx+pr[k+1]+sum << '\n';;
    sum += pr[k+1];
  }
}


#include<bits/stdc++.h>
#define mx                          100005
#define lli                         long long int
#define ulli                        unsigned long long int
#define mset(a,b)                   memset(a, b, sizeof(a))
#define infile                      freopen("in.txt", "r", stdin);
#define outfile                     freopen ("out.txt","w",stdout);
#define fileclose                   fclose (stdin); fclose (stdout);
#define test_case                   lli T; cin>>T;for(lli t=1;t<=T;t++)
#define scani(x)                    scanf("%d",&x);
#define printi(x)                   printf("%d\n",x);
#define scanli(x)                   scanf("%lld",&x);
#define printli(x)                  printf("%lld\n",x);
#define frep(i,from,to)             for(lli i=from;i<=to;i++)
#define frev(i,from,to)             for(lli i=from;i>=to;i--)

using namespace std;

lli n;
lli arr[50];

lli ans = 1e18;
lli prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
bool isSet(lli num, lli pos)
{
	return (num & (1 << pos));
}
void fun()
{
	frep(mask, 0, (1 << 15) - 1)
	{
		lli num = 1;
		frep(pos, 0, 15)
		{
			if (isSet(mask, pos))
			{
				num *= prime[pos];
			}
		}
		bool flag = true;
		frep(i, 1, n)
		{
			if (__gcd(num, arr[i]) == 1)
			{
				flag = false;
				break;
			}
		}
		if (flag)
			ans = min(ans, num);
	}


}
int main()
{

	cin >> n;
	frep(i, 1, n)
	{
		cin >> arr[i];
	}
	fun();
	cout << ans << "\n";

}




