Maximum consecutive subsequence

Given a sequence of nn integer numbers x1xnx_1 \dots x_n, and an integer number xx, let L(x)L(x) be the maximum length of all the subsequences made up of only xx. That is, L(x)L(x) is the maximum number of times that xx appears consecutively in the sequence (or zero, if xx is not there). Given several xx, can you compute each L(x)L(x)?

Input

Input consists of several cases. Every case begins with nn, followed by x1xnx_1 \dots x_n, followed by a natural number qq, followed by qq different integer numbers xx about which you are asked.

Output

For every case, print a line with the qq answers L(x)L(x) separated with spaces.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T12:05:45.976Z

© Jutge.org, 2006–2026.
https://jutge.org