#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORX(i, a, b, x) FOR (ll i = (a); i <= (b); i+=x)
#define debug(x) cerr << #x << " is= " << x << endl; //use FOR debugging
#define read(a) int a; cin >> a;
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define mp(a,b) make_pair(a,b)
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vov        vector<vector<int>> 
#define pr         pair<int,int>
#define vpll       vector<pair<ll,ll>>
#define all(v)     v.begin(),v.end()
#define rall(v)    v.rbegin(),v.rend()  //reverse of above;
#define sz(container) int((container).size())
#define cut(x) {cout<<x<<"\n"; return;}
#define setprec(x) cout << fixed << showpoint << setprecision(15)<<x<<"\n";
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define time cout << clock() / double(CLOCKS_PER_SEC) << endl;
#define endl "\n";
#define cntbit(x) __builtin_popcount(x);
#define fi first
#define se second
#define mod 1000000007
#define mod1 998244353
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
//*s.find_by_order() ->returns an iterator to the k-th largest element (counting from zero);
//s.order_of_key() ->number of elements strictly smaller then our item;
//st.rbegin()->second; last element in set
//st.erase(prev(st.end())); delete last element in set;
//sort(a+1,a+n+1,[](ll x,ll y){return abs(x)>abs(y);});
//sort(v.begin(), v.end(), greater<int>()); 
const int N=2e5+5;
const ll inf=1e18;
ll n,a[N],ma=0;
set<ll>s;
void solve()
{
 FOR(i,1,n)
 {
  s.insert(a[i]);
   if(ma==a[i])
  {
    while(s.find(ma)!=s.end()) ma++;
  }
  cout<<ma<<endl;
 }
}
int main()
{
  
  fast_io;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  cin>>n;
  FOR(i,1,n) cin>>a[i];
  solve();
}
#include<bits/stdc++.h>
using namespace std;
 
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"
const int maxr = 1e5 + 5;

int solve(int idx, vector<bool> &vis, string &s) {

    if(idx == 4) {
        int flag = 1;
        for(int i = 0; i < 10; i++) {
            if(s[i] == 'o' && !vis[i])
                flag = 0;
        }
        return flag;
    }
    int cnt = 0;
    for(int i = 0; i < 10; i++) {
        if(s[i] == 'o' || s[i] == '?') {
            bool temp = vis[i];
            vis[i] = true;
            cnt += solve(idx + 1, vis, s);
            vis[i] = temp;
        }
    }
    return cnt;
}

int32_t main()
{
    GO;
    string s;
    cin >> s;

    int cnt = 0;
    for(auto x: s)
        if(x == 'o') cnt++;

    if(cnt > 4) {
        cout << 0 << endl;
        return 0;
    }
    vector<bool> vis(10, 0);
    int ans = solve(0, vis, s);
    cout << ans << endl;
    return 0;
}