Problem: Example

Input

2
10 10


Output

40.00000000

Solution (in CPP):

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

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