Mike is a bartender at Rico's bar. At Rico's, they put beer glasses in a special shelf. There are n kinds of beer at Rico's numbered from 1 to n. i-th kind of beer has ai milliliters of foam on it.

<image>

Maxim is Mike's boss. Today he told Mike to perform q queries. Initially the shelf is empty. In each request, Maxim gives him a number x. If beer number x is already in the shelf, then Mike should remove it from the shelf, otherwise he should put it in the shelf.

After each query, Mike should tell him the score of the shelf. Bears are geeks. So they think that the score of a shelf is the number of pairs (i, j) of glasses in the shelf such that i < j and <image> where <image> is the greatest common divisor of numbers a and b.

Mike is tired. So he asked you to help him in performing these requests.

Input

The first line of input contains numbers n and q (1 ≤ n, q ≤ 2 × 105), the number of different kinds of beer and number of queries.

The next line contains n space separated integers, a1, a2, ... , an (1 ≤ ai ≤ 5 × 105), the height of foam in top of each kind of beer.

The next q lines contain the queries. Each query consists of a single integer integer x (1 ≤ x ≤ n), the index of a beer that should be added or removed from the shelf.

Output

For each query, print the answer for that query in one line.

Examples

Input

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


Output

0
1
3
5
6
2
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Arrays;
import java.io.InputStream;
import java.util.Collection;
import java.io.OutputStreamWriter;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author ashiqmostofa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskE {
    int n;
    int q;
    long cur;
    int[] primes;
    int[] numbers;
    int[] dp;
    int[] is;
    int[] mul;
    ArrayList<Integer>[] prime_divisors;


    void primed(int n) {
        if (n == 1) return;
        if(dp[n]!=-1){
            return;
        }
        dp[n]=1;
        int cur = n;
        for (int j = 0; j < primes.length; j++) {
            if (primes[j] * primes[j] > cur) {
                break;
            }
            if (cur % primes[j] == 0) {

                while (cur % primes[j] == 0) {
                    cur /= primes[j];
                }
                prime_divisors[n].add(primes[j]);
                primed(cur);

                prime_divisors[n].addAll(prime_divisors[cur]);
                cur=1;
                break;
            }
        }

        if (cur > 1) {
            prime_divisors[n].add(cur);
        }


    }

    void fun(int val,int sign){

        for(int mask=0;mask<(1<<prime_divisors[val].size());mask++){

            if(mask==0){
                mul[mask]=1;
            }
            else {
                mul[mask] = mul[mask & (mask - 1)] * prime_divisors[val].get(Integer.numberOfTrailingZeros(mask));
            }
            if (sign < 0) {
                dp[mul[mask]]--;
            }
            if ((Integer.bitCount(mask) & 1)==1)
                cur -= dp[mul[mask]] * sign;
            else
                cur += dp[mul[mask]] * sign;
            if (sign > 0){
                dp[mul[mask]]++;
            }
        }

    }



    public void solve(int testNumber, InputReader in, OutputWriter out) {

        prime_divisors = new ArrayList[555555];
        for (int i = 0; i < 500001; i++) {
            prime_divisors[i] = new ArrayList<Integer>();
        }
        primes = IntegerUtils.generatePrimes(1000);

        dp = ArrayUtils.createArray(555555, -1);
        is = ArrayUtils.createArray(555555, 1);
        mul = ArrayUtils.createArray(555555, 1);

        for(int i=500000;i>=2;i--)primed(i);

n=in.readInt();
        q=in.readInt();
        numbers= IOUtils.readIntArray(in,n);
        dp=ArrayUtils.createArray(555555,0);
        for (int qq = 0; qq < q; qq++) {
            int w=in.readInt();
            w--;

            fun(numbers[w],is[w]);

            is[w]*=-1;
            out.printLine(cur);


        }


    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void close() {
        writer.close();
    }

    public void printLine(long i) {
        writer.println(i);
    }

}

class IntegerUtils {

    public static int[] generatePrimes(int upTo) {
        int[] isPrime = generateBitPrimalityTable(upTo);
        IntList primes = new IntArrayList();
        for (int i = 0; i < upTo; i++) {
            if ((isPrime[i >> 5] >>> (i & 31) & 1) == 1)
                primes.add(i);
        }
        return primes.toArray();
    }

    public static int[] generateBitPrimalityTable(int upTo) {
        int[] isPrime = new int[(upTo + 31) >> 5];
        if (upTo < 2)
            return isPrime;
        Arrays.fill(isPrime, -1);
        isPrime[0] &= -4;
        for (int i = 2; i * i < upTo; i++) {
            if ((isPrime[i >> 5] >>> (i & 31) & 1) == 1) {
                for (int j = i * i; j < upTo; j += i)
                    isPrime[j >> 5] &= -1 - (1 << (j & 31));
            }
        }
        return isPrime;
    }

}

class ArrayUtils {

    public static int[] createArray(int count, int value) {
        int[] array = new int[count];
        Arrays.fill(array, value);
        return array;
    }

}

class IOUtils {

    public static int[] readIntArray(InputReader in, int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++)
            array[i] = in.readInt();
        return array;
    }

}

abstract class IntCollection {
    public abstract IntIterator iterator();
    public abstract int size();
    public abstract void add(int value);

    public int[] toArray() {
        int size = size();
        int[] array = new int[size];
        int i = 0;
        for (IntIterator iterator = iterator(); iterator.isValid(); iterator.advance())
            array[i++] = iterator.value();
        return array;
    }

}

interface IntIterator {
    public int value() throws NoSuchElementException;
    public void advance() throws NoSuchElementException;
    public boolean isValid();
}

abstract class IntList extends IntCollection implements Comparable<IntList> {

    public abstract int get(int index);

    public IntIterator iterator() {
        return new IntIterator() {
            private int size = size();
            private int index = 0;

            public int value() throws NoSuchElementException {
                if (!isValid())
                    throw new NoSuchElementException();
                return get(index);
            }

            public void advance() throws NoSuchElementException {
                if (!isValid())
                    throw new NoSuchElementException();
                index++;
            }

            public boolean isValid() {
                return index < size;
            }
        };
    }

    public int hashCode() {
        int hashCode = 1;
        for (IntIterator i = iterator(); i.isValid(); i.advance())
            hashCode = 31 * hashCode + i.value();
        return hashCode;
    }

    public boolean equals(Object obj) {
        if (!(obj instanceof IntList))
            return false;
        IntList list = (IntList)obj;
        if (list.size() != size())
            return false;
        IntIterator i = iterator();
        IntIterator j = list.iterator();
        while (i.isValid()) {
            if (i.value() != j.value())
                return false;
            i.advance();
            j.advance();
        }
        return true;
    }

    public int compareTo(IntList o) {
        IntIterator i = iterator();
        IntIterator j = o.iterator();
        while (true) {
            if (i.isValid()) {
                if (j.isValid()) {
                    if (i.value() != j.value()) {
                        if (i.value() < j.value())
                            return -1;
                        else
                            return 1;
                    }
                } else
                    return 1;
            } else {
                if (j.isValid())
                    return -1;
                else
                    return 0;
            }
            i.advance();
            j.advance();
        }
    }

}

class IntArrayList extends IntList {
    private int[] array;
    private int size;

    public IntArrayList() {
        this(10);
    }

    public IntArrayList(int capacity) {
        array = new int[capacity];
    }

    public int get(int index) {
        if (index >= size)
            throw new IndexOutOfBoundsException();
        return array[index];
    }

    public int size() {
        return size;
    }

    public void add(int value) {
        ensureCapacity(size + 1);
        array[size++] = value;
    }

    public void ensureCapacity(int newCapacity) {
        if (newCapacity > array.length) {
            int[] newArray = new int[Math.max(newCapacity, array.length << 1)];
            System.arraycopy(array, 0, newArray, 0, size);
            array = newArray;
        }
    }

    public int[] toArray() {
        int[] array = new int[size];
        System.arraycopy(this.array, 0, array, 0, size);
        return array;
    }

}
