#include <bits/stdc++.h>

using namespace std;

using i64 = int64_t;

const i64 INF = 1e18 + 7;
const i64 MOD = 1e9 + 7;

template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;


signed main(){
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for(auto& x : a){
        char s;
        cin >> s;
        if(s == 'U')
            x = 2;
        if(s == 'D')
            x = 1;
    }

    vector<mint> dp(n + 1, 0);
    dp[0] = 1;
    for(int i = 0; i < n; ++i){
        if(!a[i])
            continue;
        vector<mint> nex(n + 1, 0);
        for(int j = 0; j < n; ++j){
                if(dp[j] == mint(0))
                    continue;
                // up
                if(a[i] == 1){
                    // umeru
                    nex[j] += dp[j] * j;
                    // umenai
                    if(j)
                        nex[j - 1] += dp[j] * j * j;
                }
                // down
                else{
                    // umeru
                    nex[j] += dp[j] * j;
                    // umenai
                    nex[j + 1] += dp[j];
                }
        }
        dp = move(nex);
    }

    cout << dp[0] << endl;

}
