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

#BS0000202. Bài kiểm tra của Sakurako (Sakurako's Test)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Bài kiểm tra của Sakurako (Sakurako's Test)

Sakurako's Test

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Sakurako has an array of nn positive integers. For a given positive xx, she may repeatedly select an index ii with ai≥xa_i\ge x and subtract xx from that element. The median is the element at one-based position ⌊n/2⌋+1\lfloor n/2\rfloor+1 after sorting, including the right middle position for even nn. For each of qq values of xx, determine the minimum attainable median. Queries independently start with the original array.

Input

The first line gives integers n,qn,q, the array length and query count. The second gives nn integers aia_i. Each of the next qq lines contains one integer xx.

Output

Print qq integers on one line, in query order.

Subtasks

  • Subtask 1 (20 points): 1≤n,q≤1001\le n,q\le 100; 1≤ai≤n1\le a_i\le n for 1≤i≤n1\le i\le n; 1≤x≤n1\le x\le n in each query.
  • Subtask 2 (30 points): 1≤n,q≤20001\le n,q\le 2000; 1≤ai≤n1\le a_i\le n for 1≤i≤n1\le i\le n; 1≤x≤n1\le x\le n in each query.
  • Subtask 3 (50 points): 1≤n,q≤1000001\le n,q\le 100000; 1≤ai≤n1\le a_i\le n for 1≤i≤n1\le i\le n; 1≤x≤n1\le x\le n in each query.

Examples

Input

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

Output

0 1 1 1 2

Explanation

For each x, reducing every entry as far as permitted yields sorted arrays [0,0,0,0,0], [0,0,1,1,1], [0,1,1,2,2], [0,1,1,2,3], and [0,1,2,3,4]. The third entry gives the five answers. No entry can be reduced below its remainder.