#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;
}
