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

#BS0000127. Biến đổi tất cả phần tử về cùng giá trị (±1 Operation 2)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Biến đổi tất cả phần tử về cùng giá trị (±1 Operation 2)

±1 Operation 2

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

You are given an integer array A1,…,AnA_1,\ldots,A_n. One operation chooses a single index and increments or decrements its value by exactly 11. For each of qq independent queries XjX_j, find the minimum number of operations required to make every element equal to XjX_j. The original array is unchanged between queries.

Input

The first line contains n,qn,q. The second line contains nn values AiA_i. Each of the following qq lines contains one target value XjX_j.

Output

Print qq lines, each giving the minimum operations needed to make all entries equal to its target.

Subtasks

  • Subtask 1 (20 points): 1≤n,q≤251\le n,q\le 25; 0≤Ai,Xj≤1090\le A_i,X_j\le 10^9 for 1≤i≤n1\le i\le n, 1≤j≤q1\le j\le q.
  • Subtask 2 (30 points): 1≤n,q≤30001\le n,q\le 3000; 0≤Ai,Xj≤1090\le A_i,X_j\le 10^9 for 1≤i≤n1\le i\le n, 1≤j≤q1\le j\le q.
  • Subtask 3 (50 points): 1≤n,q≤2000001\le n,q\le 200000; 0≤Ai,Xj≤1090\le A_i,X_j\le 10^9 for 1≤i≤n1\le i\le n, 1≤j≤q1\le j\le q.

Examples

Input

5 3
6 11 2 5 5
5
20
0

Output

10
71
29

Explanation

For X=5X=5, the distances are 1,6,3,0,01,6,3,0,0, summing to 1010. For X=20X=20, the required increments are 14,9,18,15,1514,9,18,15,15, totaling 7171. For X=0X=0, the decrements sum to 6+11+2+5+5=296+11+2+5+5=29. Thus print 10, 71, and 29.