求助,这段代码为什么会RE,想不明白
import sys
input = sys.stdin.readline
from sortedcontainers import SortedList
n, q = map(int, input().split())
a = list(map(int, input().split()))
st = SortedList(a)
for _ in range(q):
opt, x = map(int, input().split())
if opt == 1:
if st.count(x):
st.remove(x)
else:
print(-1)
continue
else:
st.add(x)
print(2*(st[-1]-st[0]))