Problem: Example

Input

2
10 10


Output

40.00000000

Solution (in CPP):

Solution:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const double inf=1e8;
int main(){
	int n;
	cin>>n;
	vd dp(n),in(n);
	rep(i,n)cin>>in[i];
	rep(i,n){
		dp[i]=in[i];
		rep(j,i)dp[i]=max<double>(dp[i],dp[j]+2*sqrt(in[i]*in[j]));
	}
	rep(i,n)dp[i]+=in[i];
	rep(i,n-1)dp[i+1]=max<double>(dp[i],dp[i+1]);
	cout<<shosu(9)<<dp[n-1]<<endl;
}