Problem: Example

Input

2
10 10


Output

40.00000000

Solution (in CPP):

Solution:
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int b[110000];
double c[11000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	c[0]=(double)b[0];
	for(int i=1;i<a;i++){
		c[i]=(double)b[i];
		for(int j=0;j<i;j++){
			c[i]=max(c[i],c[j]+2.0*sqrt(b[i]*b[j]));
		}
	}
	double ret=0;
	for(int i=0;i<a;i++)ret=max(ret,c[i]+(double)b[i]);
	printf("%.12f\n",ret);
}