No submission language available for this problem.
Description
Jeevan has two arrays a and b of size n. He is fond of performing weird operations on arrays. This time, he comes up with two types of operations:
Choose any i (1≤i≤n) and increment aj by 1 for every j which is a multiple of i and 1≤j≤n.
Choose any i (1≤i≤n) and decrement aj by 1 for every j which is a multiple of i and 1≤j≤n.
He wants to convert array a into an array b using the minimum total number of operations. However, Jeevan seems to have forgotten the value of b1. So he makes some guesses. He will ask you q questions corresponding to his q guesses, the i-th of which is of the form:
If b1=xi, what is the minimum number of operations required to convert a to b?
Help him by answering each question.
The first line contains a single integer n(1≤n≤2⋅105) — the size of arrays a and b.
The second line contains n integers a1,a2,...,an(1≤ai≤106).
The third line contains n integers b1,b2,...,bn(1≤bi≤106 for i=1; b1=−1, representing that the value of b1 is unknown).
The fourth line contains a single integer q(1≤q≤2⋅105) — the number of questions.
Each of the following q lines contains a single integer xi(1≤xi≤106) — representing the i-th question.
Output q integers — the answers to each of his q questions.
Input
The first line contains a single integer n(1≤n≤2⋅105) — the size of arrays a and b.
The second line contains n integers a1,a2,...,an(1≤ai≤106).
The third line contains n integers b1,b2,...,bn(1≤bi≤106 for i=1; b1=−1, representing that the value of b1 is unknown).
The fourth line contains a single integer q(1≤q≤2⋅105) — the number of questions.
Each of the following q lines contains a single integer xi(1≤xi≤106) — representing the i-th question.
Output
Output q integers — the answers to each of his q questions.