Wrong answer altough the sample input is correct?

Question Link :Contest Page | CodeChef

#include<iostream>
using namespace std;

int main()
{
int t;
cin>>t;
while(t--)
{
int n=0, z=0,max=-10000,k=0;
cin>>n;
while(n--)
{
cin>>z;
k+=z;
if(k>max)
max=k;
}
cout<<max<<endl;
}
}

It is not necessary that the subarray you pick should start from first index.