Problem: Example

Input

2
10 10


Output

40.00000000

Solution (in CPP):

Solution:
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int N;
	cin>>N;
	vector<double> R(N),D(N);
	double ans=0;
	for(int i=0;i<N;i++){
		cin>>R[i];
		D[i]=R[i];
		for(int j=0;j<i;j++){
			D[i]=max(D[j]+2*sqrt(R[i]*R[j]),D[i]);
		}
		ans=max(ans,D[i]+R[i]);
	}
	cout<<fixed;
	cout.precision(8);
	cout<<ans<<endl;

	return 0;
}