Maximum Subarray sum doubt

int cumulativeSum(int n,int a[]){
int s[n] = {};
s[0] = a[0];
for (int i=1;i<n;i++){
s[i] += s[i-1] + a[i];
}
int sum = INT_MIN;
for (int i=0;i<n;i++){
for (int j=i;j<n;j++){
if (sum < s[j] - s[i-1])
sum = s[j] - s[i-1];
}
}
return sum;
}
In the above piece of code, In the nested loop if have written if (sum < s[j] - s[i - 1]) why this line is not giving runtime error as i ranges from 0 to n and at some instance i - 1 = -1, it results to out of bounds of array. but the code is running well.

I got that, but the same is written on g