#include<algorithm>
#include<iostream>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define neinf 0xc0c0c0c0c0c0c0c0ll
#define inf 0x3f3f3f3f3f3f3f3fll
#define uint unsigned int
#define ull unsigned ll
#define HgS 1000000007
#define ll long long
#define reg register
#define opr operator
#define ret return
#define gc getchar
#define pc putchar
#define cst const
#define db double
#define il inline
il ll rd()
{
	reg ll res=0,lab=1;
	reg char ch=gc();
	while((ch<'0'||ch>'9')&&ch!=EOF)
	{if(ch=='-')lab=-lab;ch=gc();}
	while(ch>='0'&&ch<='9')
		res=(res<<3)+(res<<1)+(ch&15),ch=gc();
	return res*lab;
}
il void prt(ll x,char t='\n')
{
	static char ch[40];reg int tp=0;
	if(!x){fputs("0",stdout);if(t)pc(t);return;}
	if(x<0)pc('-'),x=-x;
	while(x)ch[++tp]=(x%10)^48,x/=10;
	while(tp)pc(ch[tp--]);
	if(t)pc(t);
}
il ll umax(ll a,ll b){return a>b?a:b;}
il ll umin(ll a,ll b){return a<b?a:b;}
il ll uabs(ll x){return x>0?x:-x;}
il ll qpow(ll n,ll e=HgS-2,ll p=HgS)
{
	reg ll res=1;
	while(e){if(e&1)res=res*n%p;n=n*n%p;e>>=1;}
	return res;
}
ll T,L,R;
int main()
{
	T=rd();
	while(T --> 0)
	{
		L=rd();R=rd();
		if(2*L>R)prt(0);
		else prt((R-2*L+1)*(R-2*L+2)/2);
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int 					long long
//#define double 					long double
#define max(x,y) 				(((x)>(y))?(x):(y))
#define min(x,y) 				(((x)<(y))?(x):(y))
#define all(v) 					v.begin(),v.end()
#define vi 						vector<int>
#define MOD 					1000000007
#define inf 					1e18
#define ps(num,precision) 		fixed<<setprecision(precision)<<num
#define md(arr,n,type) 			type *arr=new type[n]

 
void inout(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}
 
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
 
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
 
void SieveOfEratosthenes(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p){
				prime[i]=false;
			}
		}
	}
 
	for(int i=2;i<=n;i++){
		if(prime[i]){
		}
	}
}
int printDivisors(int n) 
{ 
	int sum=0;
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
                sum+=1;
            else{ 
                sum+=2;
            }
        } 
    } 
    return sum;
}

void solve(){
    int n;
	cin>>n;
	int a[n];
	int min;
	int ans=0;
	int con=0;
	vector<pair<int,int>> b;
	for(int i=0;i<n;i++){
		cin>>a[i];
		b.push_back(make_pair(a[i],i));
	}
	sort(all(b));
	for(int i=0;i<n;i++){
		min=a[i];
		if(ans<a[i]){
			ans=a[i];
		}
		for(int j=i+1;j<n;j++){
			if(min>a[j]){
				min=a[j];
			}
			if((j-i+1)*min>ans){
				ans=(j-i+1)*min;
			}
		}
	}
	cout<<ans;
}
int32_t main(){
	//inout();
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}