#include int main(){ using namespace std; unsigned long N; cin >> N; vector> problems(N); for(auto&& [a, _] : problems)cin >> a; for(auto&& [_, b] : problems)cin >> b; reverse(begin(problems), end(problems)); vector> stack; while(!empty(problems)){ auto [a, b]{problems.back()}; problems.pop_back(); while(!empty(stack) && (stack.back().first / stack.back().second > a / b || (stack.back().first / stack.back().second == a / b && (stack.back().first % stack.back().second) * b / stack.back().second >= a % b))){ a += stack.back().first; b += stack.back().second; stack.pop_back(); } stack.emplace_back(a, b); } long double ans{}; for(const auto& [a, b] : stack)ans += a < b ? a + b : 2 * sqrt(static_cast(a)) * sqrt(static_cast(b)); cout << fixed << setprecision(30) << ans << endl; return 0; }