#include <bits/stdc++.h>
using namespace std;
int sayi_s;
string str = "-";
string ph;
priority_queue<pair<int, pair<int, int> > > pq;
vector<pair<int, int> > komsular;
vector<int> sayilar;
int e_s, k_s;
int main() {
  cin >> sayi_s;
  cin >> ph;
  str += (ph + "-");
  sayilar.push_back(-1);
  for (int i = 1; i <= sayi_s; i++) {
    sayilar.push_back(0);
    cin >> sayilar[i];
    if (str[i] == 'B') {
      e_s++;
    } else {
      k_s++;
    }
  }
  for (int i = 0; i < sayi_s + 3; i++) {
    komsular.push_back(make_pair(i - 1, i + 1));
  }
  for (int i = 1; i <= sayi_s - 1; i++) {
    if ((str[i] == 'B' && str[i + 1] == 'G') ||
        (str[i] == 'G' && str[i + 1] == 'B')) {
      pq.push(
          make_pair(-abs(sayilar[i] - sayilar[i + 1]), make_pair(-i, -i - 1)));
    }
  }
  printf("%d\n", min(e_s, k_s));
  while (pq.size()) {
    if (komsular[-pq.top().second.first].second == -pq.top().second.second &&
        komsular[-pq.top().second.second].first == -pq.top().second.first) {
      cout << -pq.top().second.first << " " << -pq.top().second.second << "\n";
      int a, b;
      b = komsular[-pq.top().second.second].second;
      a = komsular[-pq.top().second.first].first;
      komsular[-pq.top().second.first] = make_pair(-2, -2);
      komsular[-pq.top().second.second] = make_pair(-2, -2);
      pq.pop();
      komsular[a].second = b;
      komsular[b].first = a;
      if ((str[a] == 'B' && str[b] == 'G') ||
          (str[a] == 'G' && str[b] == 'B')) {
        pq.push(make_pair(-abs(sayilar[a] - sayilar[b]), make_pair(-a, -b)));
      }
    } else {
      pq.pop();
    }
  }
  return 0;
}
