/**
 *    author:  tourist
 *    created: 26.11.2019 17:52:04       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  string s;
  cin >> s;
  int low = 1, high = n;
  while (low < high) {
    int mid = (low + high + 1) >> 1;
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
      b[i] = (a[i] >= mid);
    }
    vector<int> seq(1, 1);
    for (int i = 1; i < n; i++) {
      if (b[i] != b[i - 1]) {
        seq.push_back(1);
      } else {
        seq.back() += 1;
      }
    }
    int sz = (int) seq.size();
    vector<int> what(sz);
    for (int i = 0; i < sz; i++) {
      what[i] = (b[0] + i) % 2;
    }
    vector<set<pair<int, int>>> inner(2);
    vector<int> delta(2, 0);
    for (int i = 1; i < sz - 1; i++) {
      inner[what[i]].emplace(seq[i], i);
    }
    vector<int> pr(sz + 2);
    vector<int> ne(sz + 2);
    for (int i = 0; i < sz + 2; i++) {
      pr[i] = i - 1;
      ne[i] = i + 1;
    }
    auto Next = [&](int x) {
      return ne[x + 1] - 1;
    };
    auto Prev = [&](int x) {
      return pr[x + 1] - 1;
    };
    auto Head = [&]() {
      return ne[0] - 1;
    };
    auto Tail = [&]() {
      return pr[sz + 1] - 1;
    };
    auto Remove = [&](int x) {
      pr[ne[x + 1]] = pr[x + 1];
      ne[pr[x + 1]] = ne[x + 1];
    };
    for (char c : s) {
      int lft = Head();
      int rgt = Tail();
      if (lft == rgt) {
        break;
      }
      int u = (c == 'm' ? 0 : 1);
      delta[u] += 1;
      delta[u ^ 1] -= 1;
      if (what[lft] != u) {
        --seq[lft];
        if (seq[lft] == 0) {
          int to = Next(lft);
          Remove(lft);
          if (to == rgt) {
            break;
          }
          inner[u].erase({seq[to], to});
          seq[to] += delta[what[to]];
          lft = to;
        }
      }
      if (what[rgt] != u) {
        --seq[rgt];
        if (seq[rgt] == 0) {
          int to = Prev(rgt);
          Remove(rgt);
          if (to == lft) {
            break;
          }
          inner[u].erase({seq[to], to});
          seq[to] += delta[what[to]];
          rgt = to;
        }
      }
      while (!inner[u ^ 1].empty() && inner[u ^ 1].begin()->first + delta[u ^ 1] == 0) {
        int me = inner[u ^ 1].begin()->second;
        inner[u ^ 1].erase(inner[u ^ 1].begin());
        if (Prev(me) != lft && Next(me) != rgt) {
          inner[u].erase({seq[Prev(me)], Prev(me)});
          inner[u].erase({seq[Next(me)], Next(me)});
          seq[Prev(me)] += seq[Next(me)] + delta[u];
          inner[u].emplace(seq[Prev(me)], Prev(me));
          Remove(me);
          Remove(Next(me));
        } else {
          if (Prev(me) != lft) {
            inner[u].erase({seq[Prev(me)], Prev(me)});
            seq[Next(me)] += seq[Prev(me)] + delta[u];
            Remove(me);
            Remove(Prev(me));
          } else {
            if (Next(me) != rgt) {
              inner[u].erase({seq[Next(me)], Next(me)});
              seq[Prev(me)] += seq[Next(me)] + delta[u];
              Remove(me);
              Remove(Next(me));
            } else {
              seq[Prev(me)] += seq[Next(me)];
              Remove(me);
              Remove(Next(me));
            }
          }
        }
      }
    }
    assert(Head() == Tail());
    if (what[Head()] == 1) {
      low = mid;
    } else {
      high = mid - 1;
    }
  }
  cout << low << '\n';
  return 0;
}


Measured memory_bytes: 4296