Let's say you are standing on the XY-plane at point (0, 0) and you want to reach point (n, n).

You can move only in two directions: 

  * to the right, i. e. horizontally and in the direction that increase your x coordinate, 
  * or up, i. e. vertically and in the direction that increase your y coordinate. 



In other words, your path will have the following structure: 

  * initially, you choose to go to the right or up; 
  * then you go some positive integer distance in the chosen direction (distances can be chosen independently); 
  * after that you change your direction (from right to up, or from up to right) and repeat the process. 



You don't like to change your direction too much, so you will make no more than n - 1 direction changes.

As a result, your path will be a polygonal chain from (0, 0) to (n, n), consisting of at most n line segments where each segment has positive integer length and vertical and horizontal segments alternate.

Not all paths are equal. You have n integers c_1, c_2, ..., c_n where c_i is the cost of the i-th segment.

Using these costs we can define the cost of the path as the sum of lengths of the segments of this path multiplied by their cost, i. e. if the path consists of k segments (k ≤ n), then the cost of the path is equal to ∑_{i=1}^{k}{c_i ⋅ length_i} (segments are numbered from 1 to k in the order they are in the path).

Find the path of the minimum cost and print its cost.

Input

The first line contains the single integer t (1 ≤ t ≤ 1000) — the number of test cases.

The first line of each test case contains the single integer n (2 ≤ n ≤ 10^5).

The second line of each test case contains n integers c_1, c_2, ..., c_n (1 ≤ c_i ≤ 10^9) — the costs of each segment.

It's guaranteed that the total sum of n doesn't exceed 10^5.

Output

For each test case, print the minimum possible cost of the path from (0, 0) to (n, n) consisting of at most n alternating segments.

Example

Input


3
2
13 88
3
2 3 1
5
4 3 2 1 4


Output


202
13
19

Note

In the first test case, to reach (2, 2) you need to make at least one turn, so your path will consist of exactly 2 segments: one horizontal of length 2 and one vertical of length 2. The cost of the path will be equal to 2 ⋅ c_1 + 2 ⋅ c_2 = 26 + 176 = 202.

In the second test case, one of the optimal paths consists of 3 segments: the first segment of length 1, the second segment of length 3 and the third segment of length 2.

The cost of the path is 1 ⋅ 2 + 3 ⋅ 3 + 2 ⋅ 1 = 13.

In the third test case, one of the optimal paths consists of 4 segments: the first segment of length 1, the second one — 1, the third one — 4, the fourth one — 4. The cost of the path is 1 ⋅ 4 + 1 ⋅ 3 + 4 ⋅ 2 + 4 ⋅ 1 = 19.
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef uint64_t bu;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpl;
typedef vector<string> vs;
typedef vector<char> vc;
#define vb vector<bool>
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define LB lower_bound
#define UB upper_bound
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repr(i, a, b) for (ll i = a; i > b; i--)
#define rept(type, i, a, op, b, change) for (type i = a; i op b; i += change) //general for loop
#define repi(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define cy cout << "YES"<<endl
#define cn cout<<"NO"<<endl
#define F first
#define S second
#define PI 3.14159265358979323846
#define W(i,n) while(i<n)
#define Sort(v) sort(begin(v),end(v))
#define M 998244353
#define MAXN 1000001
#define MOD 1000000007
#define all(v) begin(v),end(v)
#define elif else if
#define INF 1000000000000000003
#define debug(x) cout<<"#x:"<<x<<endl
//#define int ll
//ll spf[MAXN];
bool is_Smaller_str(string str1, string str2)
{
	// Calculate lengths of both string
	ll n1 = str1.length(), n2 = str2.length();

	if (n1 < n2)
	return true;
	if (n2 < n1)
	return false;

	for (int i=0; i<n1; i++)
	if (str1[i] < str2[i])
		return true;
	else if (str1[i] > str2[i])
		return false;

	return false;
}
// Graph class represents a undirected graph
// using adjacency list representation
class Graph {
    // No. of vertices
    int V;

    // Pointer to an array containing adjacency lists
    list<int>* adj;

    // A function used by DFS
    void DFSUtil(int v, bool visited[]);

public:
    // Constructor
    Graph(int V);

    void addEdge(int v, int w);
    int NumberOfconnectedComponents();
};

// Function to return the number of
// connected components in an undirected graph
int Graph::NumberOfconnectedComponents()
{

    // Mark all the vertices as not visited
    bool* visited = new bool[V];

    // To store the number of connected components
    int count = 0;
    for (int v = 0; v < V; v++)
        visited[v] = false;

    for (int v = 0; v < V; v++) {
        if (visited[v] == false) {
            DFSUtil(v, visited);
            count += 1;
        }
    }

    return count;
}

void Graph::DFSUtil(int v, bool visited[])
{

    // Mark the current node as visited
    visited[v] = true;

    // Recur for all the vertices
    // adjacent to this vertex
    list<int>::iterator i;

    for (i = adj[v].begin(); i != adj[v].end(); ++i)
        if (!visited[*i])
            DFSUtil(*i, visited);
}

Graph::Graph(int V)
{
    this->V = V;
    adj = new list<int>[V];
}

// Add an undirected edge
void Graph::addEdge(int v, int w)
{
    adj[v].push_back(w);
    adj[w].push_back(v);
}
// Function for find difference of larger numbers
string find_Diff_str(string str1, string str2)
{
	// Before proceeding further, make sure str1
	// is not smaller
	if (is_Smaller_str(str1, str2))
		swap(str1, str2);

	// Take an empty string for storing result
	string str = "";

	// Calculate length of both string
	ll n1 = str1.length(), n2 = str2.length();

	// Reverse both of strings
	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());

	ll carry = 0;

	// Run loop till small string length
	// and subtract digit of str1 to str2
	for (ll i=0; i<n2; i++)
	{
		// Do school mathematics, compute difference of
		// current digits

		ll sub = ((str1[i]-'0')-(str2[i]-'0')-carry);

		// If subtraction is less then zero
		// we add then we add 10 into sub and
		// take carry as 1 for calculating next step
		if (sub < 0)
		{
			sub = sub + 10;
			carry = 1;
		}
		else
			carry = 0;

		str.push_back(sub + '0');
	}

	// subtract remaining digits of larger number
	for (ll i=n2; i<n1; i++)
	{
		ll sub = ((str1[i]-'0') - carry);

		// if the sub value is -ve, then make it positive
		if (sub < 0)
		{
			sub = sub + 10;
			carry = 1;
		}
		else
			carry = 0;

		str.push_back(sub + '0');
	}

	// reverse resultant string
	reverse(str.begin(), str.end());

	return str;
}
string find_sum_str(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}

void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll Rselect(vector<ll> v, ll i, ll l, ll r); //finding the ith order statistic
ll partition(vector<ll> v, ll l, ll r);
void scanc(vc& v,ll n)
{
    rep(i,0,n)
    {
        char num;
        cin>>num;
        v.pub(num);
    }
}
void scanP(vpl& v,ll n)
{
    rep(i,0,n)
    {
        ll num1,num2;
        cin>>num1>>num2;
        pair<ll,ll> p = {num1,num2};
        v.pub(p);
    }
}
template<typename T>
ostream& operator<<(ostream& stream, const vector<T>& vec) //outputting a vector
{
	for (auto& i : vec)
	{
		stream << i << ' ';
	}
	stream << '\n';
	return stream;
}

template<class T>
istream& operator>>(istream& stream, vector<T>& vec) //input for vectors of fixed size
{
	for (auto& i : vec)
	{
		stream >> i;
	}
	return stream;
}

void solve();

/*void sieve()
{
    spf[1] = 1;
    for (ll i=2; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (ll i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (ll j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                {
                if (spf[j]==j)
                    spf[j] = i;
                }
        }
    }
}
vector<ll> getFactorization(ll x)
{
    vector<ll> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}*/

void scanN(vector<ll>&v,ll n)
{
    rep(i,0,n)
    {
        ll num;
        cin>>num;
        v.pub(num);
    }
}
void scans(vector<string>& v,ll n)
{
    rep(i,0,n)
    {
        string s;
        cin>>s;
        v.pub(s);
    }
}

ll modfactorial(ll n,ll p)
{
    if(n>=p)
    return 0;
    ll result = 1;
    rep(i,1,n+1)
    {
        result = result*i;
        result = result%p;
    }
    return result;
}
ll MI(ll a, ll b,ll s0 = 1,ll s1 = 0)
{
    ll k = b;
    if(b == 0)
    return s0;
    else
    {
       return  MI(b,a%b,s1,s0-s1*(a/b));

    }
}
ll choose(ll a,ll b,ll c = MOD)
{
    if(a<b)
    return 0;
    ll x = modfactorial(a,c);
    ll y = modfactorial(b,c);
    ll z = modfactorial(a-b,c);
    ll y_ = MI(y,c,1,0);
    if(y_<0)
    y_ = y_+c;
    ll z_ = MI(z,c,1,0);
    if(z_<0)
    z_ = z_+c;
    ll mul = (x*y_)%c;
    mul = (mul*z_)%c;
    return mul;
}
void SOLT()
{
    int test;
    cin>>test;
    while(test--)
    {
        solve();
    }
}
ll modpow(ll n,ll p,ll k)
{
    n = n%k;
    ll res = 1;
    while(p>0)
    {
        if(p%2 == 1)
        res = res*n%k;
        n = n*n%k;
        p = p/2;
    }
    return res;
}
ll __pow(ll n,ll p)
{
    ll res = 1;
    while(p>0)
    {
        if(p%2 == 1)
        res = res*n;
        n = n*n;
        p = p/2;
    }
    return res;
}
ll str_mod_num(string b,ll c)
{
    ll k = b.size();
    vll mod(k+1);
    mod[0] = 1;
    //vll mod(k+1)
    rep(i,1,k+1)
    {
        mod[i] = 10*mod[i-1];
        mod[i]%=c;
    }
    ll rem = 0;
    repr(i,k-1,-1)
    {
        ll num = b[i] - '0';
        num*=mod[k-1-i];
        num%=c;
        rem+=num;
        rem%=c;
    }
    return rem;
}
ll str_pow_str_mod_num(string b,string n,ll c)
{
    ll tr = n.size();
    ll rem = str_mod_num(b,c);
    ll time_pass = n[0] - '0';
    ll ans = modpow(rem,time_pass,c);
    rep(i,1,tr)
    {
         time_pass = n[i] - '0';
        ans = modpow(ans,10,c);
        ans*=modpow(rem,time_pass,c);
        ans%=c;
    }
    return ans;
}
bool isPrime(ll a) {
    if(a == 1)
    return 0;
	for(ll i = 2; i * i <= a; ++i)
		if(a % i == 0)
			return false;
	return true;
}

bool useflushdivisible(ll a) {
	cout<<a<<endl;
	fflush(stdout);
	char sl[10];
	scanf("%s", sl);
	return sl[0] == 'y' || sl[0] == 'Y';
}
ll phi(ll n)
{
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n =n/ i;
            result =result - result / i;
        }
    }
    if (n > 1)
        result =result - result / n;
    return result;
}
bool cmp(pll x,pll y)
{
    if(x.F == y.F)
    return x.S<y.S;
    return x.F<y.F;

}
vll getfactors(ll n)
{
    vll factors;
    rep(i,1,sqrt(n)+1)
    {
        if(n%i == 0)
        {
            factors.pub(i);
            if(i!=(n/i))
            factors.pub(n/i);
        }
    }
    return factors;
}
ll Binary_Search(vector<ll>& a,ll low,ll high,ll key)
{
    if(high<low)
        return a[low-1];
    ll mid  = low+(high-low)/2;
    if(key == a[mid])
        return a[mid];
    else if(key<a[mid])
        return Binary_Search(a,low,mid-1,key);
    return Binary_Search(a,mid+1,high,key);
}
double area(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3)
{

   return abs((x1*(y2-y3) + x2*(y3-y1)+ x3*(y1-y2))/2.0);
}


/* A function to check whether point P(x, y) lies inside the triangle formed

   by A(x1, y1), B(x2, y2) and C(x3, y3) */

bool isInside(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3, int x, int y)
{

   /* Calculate area of triangle ABC */

   double A = area (x1, y1, x2, y2, x3, y3);



   /* Calculate area of triangle PBC */

   double A1 = area (x, y, x2, y2, x3, y3);



   /* Calculate area of triangle PAC */

   double A2 = area (x1, y1, x, y, x3, y3);



   /* Calculate area of triangle PAB */

   double A3 = area (x1, y1, x2, y2, x, y);



   /* Check if sum of A1, A2 and A3 is same as A */

   return (A == A1 + A2 + A3);
}
ll factorial(ll n)
{
    if(n <= 1)
    return 1;
    else
    return n*factorial(n-1);
}
int fun(vll arr, int n)
{
    int x = arr[0];
    for (int i = 1; i < n; i++)
        x = x ^ arr[i];
    return x;
}
ll find_cost(vll l)
{
    ll n = l.size(),ans = 0;
    rep(i,0,n-1)
    {
        ll j = min_element(l.begin()+i,l.end())-l.begin();
        ans+=j-i+1;
        reverse(l.begin()+i,l.begin()+j+1);
    }
    return ans;
}
ll tower_of_hanoi_number_of_ways(ll n,ll a = 3)
{
    if(n == 1)
    return 1;
 /*   if(n == 2)
    {
        if(a == 3)
        return 3;
        if(a == 1)
        return 3;
        if(a == 2)
        return 3;
    }*/
    else
    {
        ll p = tower_of_hanoi_number_of_ways(n-1,1);
        ll q = tower_of_hanoi_number_of_ways(n-1,2);
        return p+q+1;
    }
}
void tower_of_hanoi_details(ll n,char a = '1',char b = '2',char c = '3')
{
    if(n == 1)
    {
        cout<<a<<" "<<c<<endl;
        return;
    }
    tower_of_hanoi_details(n-1,a,c,b);
    cout<<a<<" "<<c<<endl;
    tower_of_hanoi_details(n-1,b,a,c);
}
int32_t main()
{

    FAST();
 //  srand(time(0));
 //SOLT();
 //sieve();
 int test = 1;
cin>>test;
 for(int tt = 1;tt<=test;tt++)
 {
   //cout<<"case #"<<tt<<": ";
    solve();
 }
	return 0;
}
void solve()
{
    ll n;
    cin>>n;
    vll c;
    scanN(c,n);
    ll dir_c = 1;
    vll min_odd;
    vll min_even;
    ll mi_o = INF,mi_e = INF;
    vll odd_sum,even_sum;
    ll o_s = 0,e_s = 0;
    rep(i,0,n)
    {
        if(i%2)
        {
            mi_o = min(mi_o,c[i]);
            min_odd.pub(mi_o);
            o_s+=c[i];
            odd_sum.pub(o_s);
        }
        else
        {
            mi_e = min(mi_e,c[i]);
            min_even.pub(mi_e);
            e_s+=c[i];
            even_sum.pub(e_s);
        }
    }
    ll ans = INF;
    while(dir_c<=n-1)
    {
        if(dir_c%2)
        {
            ll t = odd_sum[(dir_c)/2];
            t+=(n-1-dir_c/2)*min_odd[(dir_c)/2];
            t+=even_sum[(dir_c)/2];
            t+=(n-1-dir_c/2)*min_even[(dir_c)/2];
            ans = min(ans,t);
        }
        else
        {
            ll t = odd_sum[(dir_c-1)/2];
            t+=(n-1-(dir_c-1)/2)*min_odd[(dir_c-1)/2];
            t+=even_sum[(dir_c-1)/2+1];
            t+=(n-1-(dir_c-1)/2-1)*min_even[(dir_c-1)/2+1];
            ans = min(ans,t);
        }
        dir_c++;
    }
    cout<<ans<<endl;
    
}
ll Rselect(vector<ll> v, ll i, ll l, ll r)
{
	if (l == r)
		return v[l];
	ll pivot = partition(v, l, r);
	if (pivot == i)
		return v[pivot - 1];
	else if (pivot < i)
	{
		return Rselect(v, i, pivot, r);
	}
	else
	{
		return Rselect(v, i, l, pivot - 2);
	}
}

ll partition(vector<ll> v, ll l, ll r)
{
	ll pivot_index = rand() % (r - l + 1) + l;
	swap(v[pivot_index], v[l]);
	ll i = l + 1, j = l + 1;
	while (j <= r)
	{
		if (v[j] < v[l])
		{
			swap(v[j], v[i]);
			i++;
		}
		j++;
	}
	swap(v[l], v[i - 1]);
	return i;
}