#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    int *answers = new int[t];
    for (int i = 0; i < t; i++)
    {
        int n, q;
        cin >> n >> q;
        int *a = new int[n];
        for (int i = 0; i < n; i++)
            cin >> a[i];

        int count  = 0;
        if (q == 50)
        {
            for (int j = 0; j < n; j++)
            {
                int c_1 = 0;
                int c_0 = 0;

                for (int k = j; k < n; k++)
                {
                    if (a[k] == 0)
                        c_0++;
                    else
                        c_1++;

                    if(c_1 >= c_0)
                        count++;
                }
            }
        }
        else
        {
            for (int j = 0; j < n; j++)
            {
                int s = 0;
                int c = 0;
                for (int k = j; k < n; k++)
                {
                    s += a[k];
                    c++;
                    if (100*s >= q*c)
                        count++;
                }
            }
        }

        delete[] a;

        answers[i] = count;
    }

    for (int i = 0; i < t; i++)
    {
        if (i != 0)
            cout << " ";
        cout << answers[i];
    }

    delete[] answers;
}
