Max subarray sum problem

problem: https://hack.codingblocks.com/contests/c/452/1259
my solution : https://ide.codingblocks.com/#/s/20141

everything is working fine but still there is run error.
PLS HELP!!

Your code gives wrong output for input such as
1
6
-2 -8 -5 11 -7 -1

It gives output as 3 but the actual answer should be 11…

there is no code in link
check this
#include <bits/stdc++.h>
using namespace std;

int main()
{
int t;cin>>t;
while(t–>0){
long long int n,a[100000];
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
long long int dp[100000];
long long int ans=a[0];
dp[0]=a[0];
for(int i=1;i<n;i++){
dp[i]=max((dp[i-1]+a[i]),a[i]);
ans=max(ans,dp[i]);
}
cout<<ans<<endl;
}
return 0;
}