#include <bits/stdc++.h>   using namespace std;   const int MAXN = 132674;   const int MOD = 1e9 + 7;   int main() {     set<int> ar;     set<int> to_buy;     set<int> to_sell;     long long multiplyier = 1;     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int temp;       string l;       cin >> l;       scanf( %d , &temp);       if (l.size() == 3) {         if (to_buy.size() > 0 && *to_buy.rbegin() > temp) {           to_buy.insert(temp);         } else if (to_sell.size() > 0 && *to_sell.begin() < temp) {           to_sell.insert(temp);         } else           ar.insert(temp);       } else {         if (ar.find(temp) != ar.end()) {           for (auto u : ar) {             if (u != temp) {               if (u < temp)                 to_buy.insert(u);               else                 to_sell.insert(u);             }           }           ar.clear();           multiplyier = (multiplyier * 2) % MOD;         } else if (to_buy.find(temp) != to_buy.end()) {           if (*to_buy.rbegin() != temp) {             cout << 0;             return 0;           }           to_buy.erase(temp);           for (auto u : ar) to_sell.insert(u);           ar.clear();         } else if (to_sell.find(temp) != to_sell.end()) {           if (*to_sell.begin() != temp) {             cout << 0;             return 0;           }           to_sell.erase(temp);           for (auto u : ar) to_buy.insert(u);           ar.clear();         }       }     }     cout << (multiplyier * ((int)ar.size() + 1)) % MOD;     return 0;   }   