# Joker's GCD Test

BRACU Traction Inter Univ...
Limits 4s, 1.0 GB

Joker has a sequence $P$ of $n$ integers. Each two elements in the sequence are pairwise distinct. He defines the strength of the sequence as the expected value of the greatest common divisor (GCD) of any two randomly chosen distinct numbers from the sequence.

Joker will perform $q$ updates on the sequence. The updates will be of the form:

• $\texttt{1 x}$: Add $x$ to the sequence. It is guaranteed that $x$ does not exist in the sequence.
• $\texttt{2 x}$: Remove $x$ from the sequence. It is guaranteed that $x$ exists in the sequence.

To save Gotham from Joker, you must answer him the strength of the sequence after each update.

## Input

First line of input contains $n$ - denoting the initial length of the sequence ($1 \le n \le 10^6$).

Second line contains $n$ space separated integers - the initial elements of the sequence ($1 \le P_i \le 10^6$).

Third line contains $q$ - denoting the number of updates ($1 \le q \le 10^6$).

Each of the next $q$ lines describes an update of the form : either $\texttt{1 x}$ or $\texttt{2 x}$ ($1 \le x \le 10^6$).

There will be at least one add and one remove operation.

The sequence will always contain at least two elements at any point.

## Output

For each update, output in a single line the strength of the sequence after the update.

It can be shown that the strength can be always expressed as a fraction $P / Q$, where $P$ and $Q$ are co-prime integers, $P \ge 0$, $Q > 0$ and $Q$ is co-prime with $998244353$. You should compute $P ⋅ Q^{-1} \mod 998244353$, where $Q^{-1}$ denotes the multiplicative inverse of $Q \mod 998244353$.

## Sample

InputOutput
3
1 3 5
5
1 2
2 3
1 4
2 1
1 3

1
1
166374060
332748119
166374060