#include <bits/stdc++.h>
using namespace std;
int n, jsq = 0;
struct node
{
	int c; int s; int x;
}a[100005];
int digit(int x)
{
	int y = (int)sqrt(x);
	return y;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin>> a[i].c;
		a[i].s = i;	
		a[i].x = a[i].c;
	}
	
	for (int i = 1; i < n; i++)
		for (int j = 1; j <= n - i; j++)
			if(a[j].x < a[j + 1].x)
			{
				swap(a[j].x, a[j + 1].x);
				swap(a[j].s, a[j + 1].s);
			}
	for(int i = 1; i <= n; i++)
	{
		if(a[1].s == 1) continue;
		for(int j = 1; j <= a[i].s - 1; j++)
			a[i].x = digit(a[i].x);
		cout << a[i].x << endl;		 
	}
	for (int i = 1; i <= n; i++)
	{
		jsq += a[i].x;
//		cout << a[i].x << endl;
	}
	cout << jsq;
	return 0;
}