Is the code correct for all integers positive and negative?

#include <bits/stdc++.h>

using namespace std;

int main()

{

ios_base::sync_with_stdio(false);

cin.tie(NULL);cout.tie(NULL);

```
long int n;
cin>>n;
long int k;
cin>>k;
long long int a[n],i,len=0,sum=0;
unordered_map<long long int,int> m;
m[0]=-1;
for(i=0;i<n;++i)
cin>>a[i];
for(i=0;i<n;++i)
{
sum+=a[i];
if(m.find(sum)==m.end())
m[sum]=i;
if(m.find(sum-k)!=m.end() && len<i-m[sum-k])
{
len=i-m[sum-k];
}
}
cout<<len;
return 0;
```

}