Problem: Example

Input

2
10 10


Output

40.00000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n;
  cin >> n;
  int r[n];
  REP(i,n)cin>>r[i];
  double pos[n];
  REP(i,n){
    pos[i]=r[i];
    REP(j,i){
      pos[i] = max(pos[i],pos[j]+sqrt( (double)(4*r[i]*r[j]) ));
    }
  }
  double mx = 0;
  REP(i,n) mx = max(mx,pos[i]+r[i]);
  cout.precision(15);
  cout << fixed << mx << endl;
  return 0;
}