What is problem in my solution

i am getting additional 10 in my final answer. first i did enter the number of test case, then entered the array, then formed the another array called sum which accounts the sum of all subarrays by brute force, then pointed the maxsum to end index of the sum array which holds the sum of longest subarray which array itself, then subtracted the indexes from maxsum to find the max sub array sum. plz help me .

#include
using namespace std;

int main()
{
int t;
cin >> t;
int currentsum, maxSum;
while (t–)
{
currentsum = 0;
maxSum = 0;
int n;
cin >> n;
int arr[n];
int s[n];
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}

    s[0] = arr[0];
    for (int i = 1; i < n; i++)
    {
        s[i] = arr[i] + s[i - 1];
    }
    maxSum = s[n - 1];
    for (int i = 0; i < n; i++)
    {
        currentsum = currentsum + (s[n - 1] - s[i]);

        if (currentsum > maxSum)
        {
            maxSum = currentsum;
        }
    }
    cout << maxSum << endl;
    
}

return 0;

}

hi @yamangoyal100_ff74db54bdf01539, this is not the right way to do as u r using the prefix array from s[n-1] all the time it can be from any index i to any index j so use 2 for loop for getting max sum check for one i all j from i+1 to n-1