Problem: Example

Input

2
10 10


Output

40.00000000

Solution (in CPP):

Solution:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<limits>
#include<bitset>
#include<unordered_map>
#include<functional>
using namespace std;

#define rep(i,s,n) for(int i=s;i<n;i++)
#define dow(i,n,s) for(int i=n-1;i>=s;i--)
#define all(a) a.begin(),a.end()
#define Sort(a) sort(all(a))
#define Qsort(a,size) qsort(a,size,sizeof(*a),compare_int)
#define DEBUG
typedef pair<int,int> II;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
bool compare_int(const void *a,const void *b) { return *(int *)a-*(int *)b; }
bool compare_by_second(II a,II b) { return a.second!=b.second?a.second<b.second:a.first<b.first; }

const int INF = 1e+9;
const int MAX_N = 5e+2;

int N;
double res = 0;
vector<double> rad;
vector<double> cood;

void solve();

int main() {

  cin>>N;
  rad.resize(N);
  cood.resize(N);
  rep(i,0,N) cin>>rad[i];
  solve();

  return 0;
}

void solve() {

  rep(i,0,N) cood[i] = 0.0;
  cood[0] = rad[0];
  rep(i,1,N) {
    rep(j,0,i) {
      cood[i] = max(cood[i],2*sqrt(rad[i]*rad[j])+cood[j]);
    }
    cood[i] = max(cood[i],rad[i]);
  }

  rep(i,0,N) res = max(res,cood[i]+rad[i]);
  cout<<fixed<<setprecision(8)<<res<<endl;
  return ;
}