#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,INF=0x3f3f3f3f;
int read()
{
int f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
return f*x;
}
int a[N];
void solve()
{
int n = read(), m = read(), s1 = 0, s2 = 0, res = 0;
memset(a, 0, sizeof(a));
for (int i = 1; i <= n;i++)
a[i] = read();
if(a[m]>0&&m!=1)
res++,a[m]=-a[m];
s1 += a[m];
for (int i = m - 1; i > 0;i--)
{
if(a[i]+s1>0)
{
res++;
a[i] = -a[i];
}
s1 += a[i];
}
for (int i = m + 1; i <= n;i++)
{
if(a[i]+s2<0)
{
res++;
a[i] = -a[i];
}
s2 += a[i];
}
printf("%d\n", res);
}
int main()
{
int t = read();
while(t--)
{
solve();
}
return 0;
}