#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ios_base :: sync_with_stdio(false);
cin.tie(NULL);
ll n, i, t;
cin >>t;
while(t--)
{
cin >> n;
vector<ll>v(n);
for(i=0;i<n;i++)
{
cin >> v[i];
}
ll mn = 1000000000, c = 0;
for(i=0;i<n;i++)
{
if(mn > v[i])
mn = v[i];
c += mn;
}
cout << c << "\n";
}
return 0;
}
Comments
Post a Comment