Given array A of N (N <= 106 ) elements (Ai <= 109 ). Given Q queries (Q <= 106 ). Every query consist of number K (K <= 109). For every query find number of subsegments such that their maximum element is K.
Test case:
5
1 2 3 4 3
3
2
3
4
Output:
2
4
8