Help me in solving CHEFSUM problem

My issue

Can anyone help me figure out which test case my code is failing in?

My code

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, ind = -1;
        cin >> n;
        int a[n + 10], prefixSum[n + 10], suffixSum[n + 10];
        prefixSum[0] = suffixSum[n + 1] = 0;
        for (int i = 1; i <= n; cin >> a[i++]);
        for (int i = 1; i <= n; i++)
        {
            prefixSum[i] = prefixSum[i - 1] + a[i];
            suffixSum[n - i + 1] = suffixSum[n - i + 2] + a[n - i + 1];
        }
        int s, sum;
        for (int i = n; i >= 1; i--)
        {
            sum = prefixSum[i] + suffixSum[i];
            if (i == n)
            {
                s = sum;
                ind = n;
            }
            if (s >= sum)
            {
                s = sum;
                ind = i;
            }
        }
        cout << ind << endl;
    }
}

Problem Link: CHEFSUM Problem - CodeChef

What’s the point of a discussion forum if you just had to copy paste a ChatGPT response? I could’ve looked at it myself too, and I am sorry if you misinterpreted, but I need an ACTUAL PERSON to go through my code and tell me the exact issue and not just beat around the bush. All the chatGPT suggestions have been checked for and none of them is the issue.

  • If the online judge can handle N values of up to 10^5, then I’m sure it won’t matter if I take 10 more. Time Complexity remains of the same order.
  • The input loop works perfectly and there’s absolutely no issue with it.
  • The initialisation of s with the last element of the prefixSum is not an issue here because we have to find the least of all the values.

Please learn coding ethics and don’t play around here @abhaypandey114