Under construction

Still being built. Things may change

Alice in the Digital World

Time limit1sMemory limit512 MB

Summary
Find the maximum sum over subarrays whose minimum element equals m, given that the array and m are bounded by 26.
Level

Medium6 of 10

Topics
Array, Divide and conquer, Prefix sum, Greedy
Solved
No attempts yet

Problem

After returning from Wonderland, Alice needs to improve her scientific skills in this digital world. Alice decides to take part in the ACM-ICPC Asia Nha Trang Regional Contest 2016 to evaluate her actual performance. Her favorite problem in the contest is the following.

Given an array of positive integers A=a1,a2,…,anA = a_1, a_2, \ldots, a_n, a subarray Ai,jA_{i,j} of AA is a sequence of continuous elements in AA, that is, Ai,j=ai,ai+1,…,ajA_{i,j} = a_i, a_{i+1}, \ldots, a_j (where 1≤i≤j≤n1 \le i \le j \le n). The weight of Ai,jA_{i,j} is the sum of all its elements.

Given an integer mm, your task is to find the maximum weight subarray of AA that contains exactly one mm as the minimum element. You can assume that AA always contains at least one element with value mm.

Input

The input consists of several datasets. The first line of the input contains the number of datasets, which is a positive number and is not greater than 20. The following lines describe the datasets.

Each dataset is described by the following lines:

  • The first line contains 2 positive integers nn and mm (n≤105n \le 10^5; m≤26m \le 26).
  • The second line contains nn positive integers, each with value at most 26.

Output

For each dataset, write out on one line the found maximum weight.

Examples1

  1. Example 1

    Input
    1
    6 2
    1 3 2 6 2 4
    
    Expected output
    12