L4: Getting tle

#include
using namespace std;

int main()
{  typedef unsigned int  sd;
    sd n;
    sd *s;
    sd i,j;
    sd MAX;
    cout<<"Enter the number of skyscrapers"<<endl;
    cin>>n;
    s= new sd[n+1];
    cout<<"Enter the floors of skyscrapers";
    cout<<endl;
    for(i=1;i<=n;i++)
    {
        cin>>s[i];
    }
    MAX=0;
    for(i=1;i<n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(j<=n/2)
           {

              if((s[i]+s[j]+(j-i))>MAX)
              {
                  MAX=(s[i]+s[j]+(j-i));
              }
           }
           if(j>n/2)
           {
               if(s[i]+s[j]+(n-(j-i))>MAX)
                MAX=(s[i]+s[j]+(j-i));
           }
        }
    }
cout<<endl;
cout<<MAX;
}

I didnt use system(“Pause”) or getline or getch functions yet this programs says time limit exceeded

problem statement

Your algorithm runs in O(n^2) and while max n is 10^6 it’s too slow.

It’s a good idea to start with easier problems to become familiar with the environment. Also it’s a good idea to read FAQ, otherwise you will be asking soon why are you getting wrong answer, read carefully parts “How does Codechef test whether my solution is correct or not” and also “Why is my code not correct”.