#include <bits/stdc++.h>
#define int long long
using namespace std;
void IOS() {
ios::sync_with_stdio (false);
cin.tie (0);
cout.tie (0);
}
inline void read (int &x) {
int s = 0, w = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
x = s * w;
}
set<int> s;
int n, x;
char ch;
signed main() {
cin >> n;
s.insert (0);
while (n--) {
cin >> ch >> x;
if (ch == '+') {
s.insert (x);
} else if (ch == '?') {
int t = 0;
while (++t) {
if (!s.count (t * x) ) {
cout << t * x << '\n';
break;
}
}
}
}
return 0;
}