PROSUM...TLE

I have written the following code but am getting a TLE.Could someone please tell me how to decrease the time complexity.Thanks in advance.

Following is the link of the code : http://ideone.com/xtRtMI

Next time, please ask a question on editorial page - http://discuss.codechef.com/questions/39941/prosum-editorial

Your code complexity is O(n^2)

for(i=0;i<(n-1);i++)
    for(j=(i+1);j<n;j++)
        ...

@betlista I know that the code complexity is O(n^2) but I was asking for a method to decrease it so that I do not get a TLE.

read the editorial :wink:

You have to do it in O(n)