Difficulty in problem CYCLCSUM

Can someone explain why is my code giving time limit exceeded on submission.
problem link : https://www.codechef.com/COOK115B/problems/CYCLCSUM

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);cout.tie(nullptr);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<long long> A(n);
        vector<long long> x;
        for(int i=0;i<n;i++)
            cin>>A[i];
        for(int i=0;i<n;i++){
            if(i!=0){
                long long x=A.front();
                A.push_back(x);
                A.erase(A.begin());
            }
            long long max_here=0,max_sum=0;
            for(int j=0;j<n;j++){
                max_here+=A[j];
                if(max_here<0)
                    max_here=0;
                else if(max_here>max_sum)
                    max_sum=max_here;
            }
                x.push_back(max_sum);
        }
        for(int i=0;i<x.size();i++)
            cout<<x[i]<<" ";
        cout<<endl;
    }
}