Problem: Example

Input

2
10 10


Output

40.00000000

Solution (in CPP):

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

using namespace std;

int main(){
  int N; cin >> N;
  double ans = 0.;
  vector<double> xs(N), rs(N);
  for(int i=0;i<N;++i){
	cin >> rs[i];
	xs[i] = rs[i];
	for(int j=0;j<i;++j)
	  xs[i] = max(xs[i], xs[j] + 2*sqrt(rs[j]*rs[i]));
	ans = max(ans, xs[i]+rs[i]);
  }
  cout << fixed << setprecision(9) << ans << endl;
  
  return 0;
}