Please Help

Problem : (CodeChef: Practical coding for everyone)
My Solution is given TLE.
My Solution:

#include<bits/stdc++.h>
#include<algorithm>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define lli long long int
#define vi vector<lli>
#define pb push_back
#define fr(n) for(lli i=0;i<n;i++)
#include<string>
#define mp map<char,lli>
#define umap map<lli,lli>
#define test lli t;cin>>t;while(t--)
using namespace std;
int main()
{
    test
    {
        lli l,r;
        cin>>l>>r;
        lli sum=0;
        for(lli i=l;i<=r;i++)
            sum+=i;
        lli total=0;
        for(lli i=l;i<=r;i++)
        {
           sum-=i;
           total+=(sum*i);
        }
        cout<<total*2<<endl;
    }
}

is there any other approch ?? Please Help

Formulate what you are doing.

You can think of effective approach from here

You must get an idea after seeing the constraints that you simply cannot use a loop here, and also these are some of the basic algebraic formulas I think you must have used many number of times,
and I think that’s why even the question is named so.

According to your approach My solution is given wrong answer.
Solution:

#include<bits/stdc++.h>
#include<algorithm>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define lli long long int
#define vi vector<lli>
#define pb push_back
#include<string>
#define mp map<char,lli>
#define umap map<lli,lli>
#define test lli t;cin>>t;while(t--)
#define mod 1000000007
using namespace std;
int main()
{
    lli l,r;
    cin>>l>>r;
    lli sum=0;
    for(lli i=l;i<=r;i++)
        sum+=i;
    lli val=sum*sum;
    lli total=0;
    for(lli i=l;i<=r;i++)
        total+=(i*i);
    cout<<(val-total)%mod<<endl;
}

There are two things missing here :-
1. A loop for testcases
2. Overflow error