PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000247. Mike và những ly bia (Mike and Foam)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Mike và những ly bia (Mike and Foam)

Mike and Foam

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Mike manages a shelf with beer types numbered 11 through nn. Type ii has foam amount aia_i. Initially the shelf is empty. Each of qq operations toggles type xx: remove it if present, otherwise insert it. After every operation print the number of pairs i<ji<j present on the shelf with gcd⁡(ai,aj)=1\gcd(a_i,a_j)=1.

Input

Line 1 contains n,qn,q. Line 2 contains exactly nn integers a1,…,ana_1,\ldots,a_n. Each of the next qq lines contains the index xx whose presence is toggled.

Output

Print exactly qq lines; the jj-th line is the valid pair count after operation jj.

Subtasks

  • Subtask 1 (20 points): 1≤n,q≤501\le n,q\le 50; 1≤ai≤5000001\le a_i\le 500000 for every ii; 1≤x≤n1\le x\le n in every operation.
  • Subtask 2 (30 points): 1≤n,q≤30001\le n,q\le 3000; 1≤ai≤5000001\le a_i\le 500000 for every ii; 1≤x≤n1\le x\le n in every operation.
  • Subtask 3 (50 points): 1≤n,q≤2000001\le n,q\le 200000; 1≤ai≤5000001\le a_i\le 500000 for every ii; 1≤x≤n1\le x\le n in every operation.

Examples

Example 1

Input

5 6
1 2 3 4 6
1
2
3
4
5
1

Output

0
1
3
5
6
2

Explanation

The inserted values are 1, 2, 3, 4, 6; the final query removes 1.