#include <bits/stdc++.h>
#define sz(v) (int)v.size()
#define pb push_back
using namespace std;
const int MXN = (int)1e6 + 10;
int n, k;
string s;
int pos_r[MXN];
vector <int> tmp;
double a[MXN];
double f(int l, int r){
if(l + 2 == r){
return a[1];
}
if(pos_r[l + 1] == r - 1){
return min(f(l + 1, r - 1), a[1]);
}
bool sign = (s[pos_r[l + 1] + 1] == '*');//false +, true *
vector <double> temp;
temp.clear();
//cerr << l << " " << r << "\n";
for(int i = l + 1; i < r; ){
temp.pb(f(i, pos_r[i]));
i = pos_r[i] + 2;
}
if(sign){
sort(temp.begin(), temp.end());
double cur_sum = a[sz(temp)];
double tmp1;
double ret = 1.0;
for(int i = 0; i < sz(temp); ++i){
tmp1 = min(temp[i], cur_sum / (1.0 * (sz(temp) - i)));
ret *= tmp1;
cur_sum -= tmp1;
}
return ret;
}
else {
double sum = 0;
for(int i = 0; i < sz(temp); ++i){
sum += temp[i];
}
return min(sum, a[sz(temp)]);
}
}
int main(){
ios_base::sync_with_stdio(0);
cin >> k;
for(int i = 1; i <= k; ++i){
cin >> a[i];
}
cin >> s;
n = sz(s);
for(int i = 0; i < n; ++i){
if(s[i] == '('){
tmp.pb(i);
}
if(s[i] == ')'){
pos_r[tmp.back()] = i;
tmp.pop_back();
}
}
cout << fixed << setprecision(9) << f(0, n - 1);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CgojZGVmaW5lIHN6KHYpIChpbnQpdi5zaXplKCkKI2RlZmluZSBwYiBwdXNoX2JhY2sKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTVhOID0gKGludCkxZTYgKyAxMDsKCmludCBuLCBrOwpzdHJpbmcgczsKaW50IHBvc19yW01YTl07CnZlY3RvciA8aW50PiB0bXA7CmRvdWJsZSBhW01YTl07Cgpkb3VibGUgZihpbnQgbCwgaW50IHIpewogIGlmKGwgKyAyID09IHIpewogICAgcmV0dXJuIGFbMV07CiAgfQogIGlmKHBvc19yW2w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