Problem: Example

Input

2
10 10


Output

40.00000000

Solution (in CPP):

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

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int r[505];
double dp[505];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> r[i];

  REP(i, n) {
    dp[i] = r[i];
    REP(j, i) {
      chmax(dp[i], dp[j] + 2*sqrt(r[i]*r[j]));
    }
  }
  // REP(i, n) cout << dp[i] << " "; cout << endl;
  double ret = 0;
  REP(i, n) chmax(ret, dp[i]+r[i]);
  cout << fixed << setprecision(15) << ret << endl;

  return 0;
}