#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define even(x) (x % 2 == 0 ? true : false)
#define odd(x) (x % 2 ? true : false)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;
const int mod = 1e9 + 7;
//vector<vector<int>> dp(m, vector<int>(n));

struct mint {
	uint x;
	mint(): x(0) {}
	mint(ll x):x((x%mod+mod)%mod) {}
	mint operator-() const { return mint(0) - *this;}
	mint operator~() const { return mint(1) / *this;}
	mint& operator+=(const mint& a) { if((x+=a.x)>=mod) x-=mod; return *this;}
	mint& operator-=(const mint& a) { if((x+=mod-a.x)>=mod) x-=mod; return *this;}
	mint& operator*=(const mint& a) { x=(ull)x*a.x%mod; return *this;}
	mint& operator/=(const mint& a) { x=(ull)x*a.pow(mod-2).x%mod; return *this;}
	mint operator+(const mint& a) const { return mint(*this) += a;}
	mint operator-(const mint& a) const { return mint(*this) -= a;}
	mint operator*(const mint& a) const { return mint(*this) *= a;}
	mint operator/(const mint& a) const { return mint(*this) /= a;}
	mint pow(ll t) const {
		if(!t) return 1;
		mint res = pow(t/2);
		res *= res;
		return (t&1)?res*x:res;
	}
	mint inv() const { return pow(mod-2);}
	bool operator<(const mint& a) const { return x < a.x;}
	bool operator>(const mint& a) const { return x > a.x;}
	bool operator==(const mint& a) const { return x == a.x;}
	bool operator!=(const mint& a) const { return x != a.x;}
};

istream& operator>>(istream&i,mint&a) {i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a) {o<<a.x;return o;}

void	solve()
{
	int n;
	cin >> n;

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(all(a));
	mint ans = a[0] + 1;
	for (int i = 1; i < n; i++) {
		ans *= a[i] - a[i - 1] + 1;
	}
	cout << ans << endl;
}

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	solve();
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = s; i < (ll)(n); i++)

ll dis(vector<ll> r, vector<ll> g) {
  ll mi = 1000100100100100100;
  ll gn = g.size();
  ll rn = r.size();
  if (gn == 0 || rn == 0)
    return mi;
  for (auto a : r) {
    ll i = lower_bound(g.begin(), g.end(), a) - g.begin();
    if (gn > i) {
      mi = min(mi, abs(a - g[i]));
    }
    if (i > 0)
      mi = min(mi, abs(a - g[i - 1]));
  }
  return mi;
};

int main() {
  ll N;
  cin >> N;
  vector<ll> rs;
  vector<ll> gs;
  vector<ll> bs;
  rep(i, 0, 2 * N) {
    ll cute;
    string color;
    cin >> cute >> color;
    if (color == "R") {
      rs.push_back(cute);
    }
    if (color == "G") {
      gs.push_back(cute);
    }
    if (color == "B") {
      bs.push_back(cute);
    }
  }

  ll size_rs = rs.size();
  ll size_gs = gs.size();
  ll size_bs = bs.size();

  // 全て偶数
  if (size_rs % 2 == 0 && size_gs % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  // 2つ奇数
  vector<ll> even_vec;
  vector<ll> odd1_vec;
  vector<ll> odd2_vec;
  if (size_rs % 2 == 0) {
    even_vec = rs;
    odd1_vec = gs;
    odd2_vec = bs;
  }
  if (size_gs % 2 == 0) {
    even_vec = gs;
    odd1_vec = rs;
    odd2_vec = bs;
  }
  if (size_bs % 2 == 0) {
    even_vec = bs;
    odd1_vec = rs;
    odd2_vec = gs;
  }

  sort(even_vec.begin(), even_vec.end());
  sort(odd1_vec.begin(), odd1_vec.end());
  sort(odd2_vec.begin(), odd2_vec.end());

  ll cur_mini;
  cur_mini = dis(odd1_vec, odd2_vec);

  if (even_vec.size() == 0) {
    cout << cur_mini << endl;
    return 0;
  }
  ll oe1_cur_mini;
  oe1_cur_mini = dis(odd1_vec, even_vec);

  ll oe2_cur_mini;
  oe2_cur_mini = dis(odd2_vec, even_vec);

  ll ans;
  ans = min(cur_mini, oe1_cur_mini + oe2_cur_mini);
  cout << ans << endl;
  return 0;
}