#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define nloop(i,a,n) for(ll i=(n-1);i>=a;i--)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define fastio     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
#define alla(a,n) a, a + n
#define debug(x) cout<<#x<<' '<<x<<endl;
#define fst first
#define snd second
#define test() ll t;  cin>>t; while(t--)
#define INF LLONG_MAX
#define SUP -1000000001
#define arrinp(x,n,arr) loop(i,x,n){cin>>arr[i];}
#define arrout(x,n,arr) loop(i,x,n){cout<<arr[i]<<" ";}cout<<endl;
#define aout(x) for(auto a: x){cout<<a<<" ";}cout<<endl;
#define out(x) cout<<x<<endl;
#define inp(x) ll x;cin>>x;
#define line cout<<endl;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

// DO NOT USE VAR t,a;
void addEdge(vector <pair<ll, ll> > adj[], ll u,
                                     ll v, ll wt)
{
    adj[u].push_back(make_pair(v, wt));
    adj[v].push_back(make_pair(u, wt));
}
void printGraph(vector<pair<ll,ll> > adj[], ll V)
{
    ll v, w;
    for (ll u = 0; u < V; u++)
    {
        cout << "Node " << u << " makes an edge with \n";
        for (auto it = adj[u].begin(); it!=adj[u].end(); it++)
        {
            v = it->first;
            w = it->second;
            cout << "\tNode " << v << " with edge weight ="
                 << w << "\n";
        }
        cout << "\n";
    }
}
void addEdge(vector<ll> adj[], ll u, ll v)
{
    adj[u].push_back(v);
    adj[v].push_back(u);
}

// A utility function to do DFS of graph
// recursively from a given vertex u.
void DFSUtil(ll u, vector<ll> adj[],
                    vector<bool> &visited)
{
    visited[u] = true;
    cout << u << " ";
    for (ll i=0; i<adj[u].size(); i++)
        if (visited[adj[u][i]] == false)
            DFSUtil(adj[u][i], adj, visited);
}

// This function does DFSUtil() for all
// unvisited vertices.
void DFS(vector<ll> adj[], ll V)
{
    vector<bool> visited(V, false);
    for (ll u=0; u<V; u++)
        if (visited[u] == false)
            DFSUtil(u, adj, visited);
}

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
ll check(ll n)
{
    if(n <= 1)
    return 0;
    double q = 24*n+1;
    q = sqrt(q);
    q--;
    q = q/6;
    //debug(q);
    ll z = q;
    //debug(z);
    return z;
}
int32_t main() {

        fastio

        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin) ;
        freopen("output.txt", "w", stdout) ;
        #endif

        test()
        {
            inp(n)
            ll arr[n];
            ll max=-1;
            loop(i,0,n)
            {
                cin>>arr[i];
                if(arr[i]>max)
                max = arr[i];
            }
            // aout(arr);
            // debug(max);
            ll hash[100001]={0};
            hash[0] = 1;
            loop(i,0,n)
            {
                // debug(arr[i])
                hash[arr[i]]++;
            }
            //  aout(hash);
            ll pre[100001] ={0};
            pre[0] = 1;
            loop(i,1,max+1)
            {
                pre[i] = pre[i-1] + hash[i];
            }
            //  aout(pre);
            ll temp=0;
            for(ll i=max;i>=1;i--)
            {
                if(pre[i]-1>=i)
                {cout<<pre[i]<<endl;
                temp++;
                break;}
            }
            if(!temp)
            cout<<1<<endl;

        }
}


#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define nloop(i,a,n) for(ll i=(n-1);i>=a;i--)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define fastio     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
#define alla(a,n) a, a + n
#define debug(x) cout<<#x<<' '<<x<<endl;
#define fst first
#define snd second
#define test() ll t;  cin>>t; while(t--)
#define INF LLONG_MAX
#define SUP -1000000001
#define arrinp(x,n,arr) loop(i,x,n){cin>>arr[i];}
#define arrout(x,n,arr) loop(i,x,n){cout<<arr[i]<<" ";}cout<<endl;
#define aout(x) for(auto a: x){cout<<a<<" ";}cout<<endl;
#define out(x) cout<<x<<endl;
#define inp(x) ll x;cin>>x;
#define line cout<<endl;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

// DO NOT USE VAR t,a;
void addEdge(vector <pair<ll, ll> > adj[], ll u,
                                     ll v, ll wt)
{
    adj[u].push_back(make_pair(v, wt));
    adj[v].push_back(make_pair(u, wt));
}
void printGraph(vector<pair<ll,ll> > adj[], ll V)
{
    ll v, w;
    for (ll u = 0; u < V; u++)
    {
        cout << "Node " << u << " makes an edge with \n";
        for (auto it = adj[u].begin(); it!=adj[u].end(); it++)
        {
            v = it->first;
            w = it->second;
            cout << "\tNode " << v << " with edge weight ="
                 << w << "\n";
        }
        cout << "\n";
    }
}
void addEdge(vector<ll> adj[], ll u, ll v)
{
    adj[u].push_back(v);
    adj[v].push_back(u);
}

// A utility function to do DFS of graph
// recursively from a given vertex u.
void DFSUtil(ll u, vector<ll> adj[],
                    vector<bool> &visited)
{
    visited[u] = true;
    cout << u << " ";
    for (ll i=0; i<adj[u].size(); i++)
        if (visited[adj[u][i]] == false)
            DFSUtil(adj[u][i], adj, visited);
}

// This function does DFSUtil() for all
// unvisited vertices.
void DFS(vector<ll> adj[], ll V)
{
    vector<bool> visited(V, false);
    for (ll u=0; u<V; u++)
        if (visited[u] == false)
            DFSUtil(u, adj, visited);
}

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
ll check(ll n)
{
    if(n <= 1)
    return 0;
    double q = 24*n+1;
    q = sqrt(q);
    q--;
    q = q/6;
    //debug(q);
    ll z = q;
    //debug(z);
    return z;
}
int32_t main() {

        fastio

        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin) ;
        freopen("output.txt", "w", stdout) ;
        #endif

        test()
        {
            inp(n)
            ll arr[n];
            ll hash[100001]={0};
            hash[0] = 1;
            ll max=-1;
            loop(i,0,n)
            {
                cin>>arr[i];
                hash[arr[i]]++;
                if(arr[i]>max)
                max = arr[i];
            }
            ll pre[100001] ={0};
            pre[0] = 1;
            loop(i,1,max+1)
            {
                pre[i] = pre[i-1] + hash[i];
            }
            ll temp=0;
            for(ll i=max;i>=1;i--)
            {
                if(pre[i]-1>=i)
                {cout<<pre[i]<<endl;
                temp++;
                break;}
            }
            if(!temp)
            cout<<1<<endl;

        }
}


#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i=0; i<n; i++)
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n, x;
        cin>>n;
        int a[200001];
        fill_n(a, 200001, 0);
        a[0]=1;
        for(int i=0; i<n; i++){
            cin>>x;
            a[x]++;
        }
        int prefix_sum[200001], will_see[200001];
        prefix_sum[0] = will_see[0] = a[0];
        for(int i=1; i<=200000; i++){
            prefix_sum[i] = prefix_sum[i-1] + a[i];
            will_see[i] = prefix_sum[i-1] + max(0, a[i]-1);
        }
        int ans=0;
        for(int i=0; i<=200000; i++){
            if(a[i]>0){
                if(will_see[i]>=i){
                    ans = prefix_sum[i];
                }
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i=0; i<n; i++)
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n, x;
        cin>>n;
        int a[200001]={0}, till=0;
        fill_n(a, 200001, 0);
        a[0]=1;
        for(int i=0; i<n; i++){
            cin>>x;
            a[x]++;
            till = max(till, x);
        }
        int prefix_sum[200001];
        prefix_sum[0] = a[0];
        int ans=0;
        for(int i=1; i<=till; i++){
            prefix_sum[i] = prefix_sum[i-1] + a[i];
            if(a[i]>0){
                if(prefix_sum[i]>i){
                    ans = prefix_sum[i];
                }
            }
        }
        if(ans==0) cout<<1<<"\n";
        else cout<<ans<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i=0; i<n; i++)
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n+1];
        a[0] = 0;
        for(int i=1; i<=n; i++) cin>>a[i];
        sort(a+1, a+n+1);
        int i;
        for(i=n; i>=1; i--){
            if(i>=a[i]) break;
        }
        cout<<i+1<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i=0; i<n; i++)
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n, x;
        cin>>n;
        int a[200001];
        fill_n(a, 200001, 0);
        a[0]=1;
        for(int i=0; i<n; i++){
            cin>>x;
            a[x]++;
        }
        int prefix_sum[200001];
        prefix_sum[0] = a[0];
        for(int i=1; i<=200000; i++){
            prefix_sum[i] = prefix_sum[i-1] + a[i];
        }
        int ans=0;
        for(int i=0; i<=200000; i++){
            if(a[i]>0){
                if(prefix_sum[i]>i){
                    ans = prefix_sum[i];
                }
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i=0; i<n; i++)
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n, x;
        cin>>n;
        int a[200001];
        fill_n(a, 200001, 0);
        a[0]=1;
        for(int i=0; i<n; i++){
            cin>>x;
            a[x]++;
        }
        int prefix_sum[200001];
        prefix_sum[0] = a[0];
        int ans=0;
        for(int i=1; i<=200000; i++){
            prefix_sum[i] = prefix_sum[i-1] + a[i];
            if(a[i]>0){
                if(prefix_sum[i]>i){
                    ans = prefix_sum[i];
                }
            }
        }
        if(ans==0) cout<<1<<"\n";
        else cout<<ans<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main() {
    int n,t;
    cin>>t;
    while(t--) {
        vector<int>v;
        cin>>n;
        for(int i=0; i<n; i++) {
            int a;
            cin>>a;
            v.push_back(a);
        }
        sort(v.begin(),v.end());
        int k=1,cnt=0;
        for(int i=0; i<n; i++) {
            if(v[i]<=k) {
                k++;
            } else {
                if(v[i]==v.back()) {
                    if(v[i]<=k) {
                        k++;
                    }
                } else {
                    cnt++;
                    if(v[i+1]<=k+cnt) {
                        k+=cnt;
                    }
                }
            }
        }
        cout<<k<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

int main() {
    int n,t;
    cin>>t;

    while(t--) {
        vector<int>v;
        cin>>n;
        for(int i=0; i<n; i++) {
            int a;
            cin>>a;
            v.push_back(a);
        }
        sort(v.begin(),v.end());

        for(int i=n-1; i>=0; i--){
            if(v[i]<=i+1){
                cout<<i+2<<endl;
                return;
            }
        }
        cout<<1<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

int main() {
    int n,t;
    cin>>t;
    while(t--) {
        vector<int>v;
        cin>>n;
        for(int i=0; i<n; i++) {
            int a;
            cin>>a;
            v.push_back(a);
        }
        sort(v.begin(),v.end());
        int k=1,cnt=0;
        for(int i=0; i<n; i++) {
            if(v[i]<=k) {
                k++;
            } else {
                if(v[i]==v.back() && v[i]<=k) {
                    k++;
                } else {
                    cnt++;
                    if(v[i+1]<=k+cnt) {
                        k+=cnt;
                    }
                }
            }
        }
        cout<<k<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

int main() {
    int n,t;
    cin>>t;

    while(t--) {
        vector<int>v;
        cin>>n;
        for(int i=0; i<n; i++) {
            int a;
            cin>>a;
            v.push_back(a);
        }
        sort(v.begin(),v.end());
        int flag=0;
        for(int i=n-1; i>=0; i--){
            if(v[i]<=i+1){
                cout<<i+2<<endl;
                flag=1;
                break;
            }
        }
        if(flag==0){
            cout<<1<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;

int main() {
    int n,t;
    cin>>t;
    while(t--) {
        vector<int>v;
        cin>>n;
        for(int i=0; i<n; i++) {
            int a;
            cin>>a;
            v.push_back(a);
        }
        sort(v.begin(),v.end());

        int k=1,cnt=0;
        for(int i=0; i<n; i++) {
            if(v[i]<=k) {
                k++;
            } else {
                cnt++;
                if(v[i+1]<=k+cnt) {
                    k+=cnt;
                }
            }
        }
        cout<<k<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main() {
    int n,t;
    cin>>t;

    while(t--) {
        vector<int>v;
        cin>>n;
        for(int i=0; i<n; i++) {
            int a;
            cin>>a;
            v.push_back(a);
        }
        sort(v.begin(),v.end());
        int k=1,cnt=0;
        for(int i=0; i<n; i++) {
            if(v[i]<=k) {
                k++;
                // cout<<"k1: "<<k<<endl;
            } else {
                if(v[i]==v.back()) {
                    if(v[i]<=k) {
                        k++;
                        //cout<<"k2: "<<k<<endl;
                    }
                } else {
                    cnt++;
                    if(v[i+1]<=k+cnt) {
                        k+=cnt;
                        cnt=0;
                        //cout<<"k3: "<<k<<endl;
                    }
                }
            }
        }
        cout<<k<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define llu unsigned long long
#define PB push_back
#define F first
#define S second
const ll MOD = 1000000007;
const ll INF = 1000000007;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ck(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define ck(x...)
#endif

string gh = "here";

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
			freopen("input.txt", "r", stdin);
			freopen("output.txt", "w", stdout);
			freopen("err.txt", "w", stderr);
	#endif

	ll t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector < ll > a(n, 0);
		for(ll i =0;i<n;i++){
			cin>>a[i];
		}
		sort(a.begin(), a.end());
		ll ans =0;
		for(ll i = n-1;i>=0;i--){
			if(a[i] > n){
				n--;
			}
			else{
				ans++;
			}
		}
		cout<<ans<<'\n';
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define llu unsigned long long
#define PB push_back
#define F first
#define S second
const ll MOD = 1000000007;
const ll INF = 1000000007;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ck(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define ck(x...)
#endif

string gh = "here";

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
			freopen("input.txt", "r", stdin);
			freopen("output.txt", "w", stdout);
			freopen("err.txt", "w", stderr);
	#endif

	ll t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector < ll > v1((2e5)+7, 0);
		for(ll i =0;i<n;i++){
			ll q;
			cin>>q;
			v1[q]++;
		}
		ll inp = 1, wait = 0;
		for(ll i =1;i<(2e5)+5;i++){
			if(inp + wait >= i){
				inp += v1[i] + wait;
				wait = 0;
			}
			else{
				wait += v1[i];
			}
		}
		cout<<inp<<'\n';
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define llu unsigned long long
#define PB push_back
#define F first
#define S second
const ll MOD = 1000000007;
const ll INF = 1000000007;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ck(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define ck(x...)
#endif

string gh = "here";

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
			freopen("input.txt", "r", stdin);
			freopen("output.txt", "w", stdout);
			freopen("err.txt", "w", stderr);
	#endif

	ll t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector < ll > a(n, 0);
		for(ll i =0;i<n;i++){
			cin>>a[i];
		}
		sort(a.begin(), a.end());
		ll ans =0;
		for(ll i = n;i>=1;i--){
			if(a[i-1] > n){
				n--;
			}
			else{
				ans++;
			}
		}
		cout<<ans<<'\n';
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define llu unsigned long long
#define PB push_back
#define F first
#define S second
const ll MOD = 1000000007;
const ll INF = 1000000007;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ck(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define ck(x...)
#endif

string gh = "here";

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
			freopen("input.txt", "r", stdin);
			freopen("output.txt", "w", stdout);
			freopen("err.txt", "w", stderr);
	#endif

	ll t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector < ll > a(n, 0);
		for(ll i =0;i<n;i++){
			cin>>a[i];
		}
		sort(a.begin(), a.end());
		ll ans =1;
		for(ll i = n;i>=1;i--){
			if(a[i-1] > n){
				n--;
			}
			else{
				ans++;
			}
		}
		cout<<ans<<'\n';
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define llu unsigned long long
#define PB push_back
#define F first
#define S second
const ll MOD = 1000000007;
const ll INF = 1000000007;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ck(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define ck(x...)
#endif

string gh = "here";

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
			freopen("input.txt", "r", stdin);
			freopen("output.txt", "w", stdout);
			freopen("err.txt", "w", stderr);
	#endif

	ll t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		map < ll, ll > v1;
		for(ll i =0;i<n;i++){
			ll q;
			cin>>q;
			v1[q]++;
		}
		ll inp = 1, wait = 0;
		ck(v1);
		for(auto it : v1){
			ck(inp, wait, it.F, it.S);
			if(inp + wait + it.S > it.F){
				inp += it.S + wait;
				wait = 0;
			}
			else{
				wait += it.S;
			}
		}
		cout<<inp<<'\n';
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define llu unsigned long long
#define PB push_back
#define F first
#define S second
const ll MOD = 1000000007;
const ll INF = 1000000007;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ck(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define ck(x...)
#endif

string gh = "here";

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
			freopen("input.txt", "r", stdin);
			freopen("output.txt", "w", stdout);
			freopen("err.txt", "w", stderr);
	#endif

	ll t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector < ll > a(n, 0);
		for(ll i =0;i<n;i++){
			cin>>a[i];
		}
		sort(a.begin(), a.end());
		ll ans =0;
		for(ll i = n;i>=1;i--){
			if(a[i] > n){
				n--;
			}
			else{
				ans++;
			}
		}
		cout<<ans<<'\n';
	}

	return 0;
}


// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    w(t)
    {
    	int n;
    	cin>>n;
    	int a[n];
    	fr(i,1,n)
    		cin>>a[i];
    	sort(a,a+n);
    	int b[n];
        fr(i,1,n)
            b[i] = i;
        int j;
        int count=  1;
    	for(j = 1;j<=n;j++)
    	{
    		if(b[j] < a[j])
            {
                break;
            }
            else
                count++;
    	}
        int rem = 0;
        while(a[j] != b[j])
        {
            rem++;
            j++;
        }
        if(rem > n-j+1)
            cout<<count<<endl;
        else
        {
            rem += 1;
            cout<<(count + rem)<<endl;
        }
    }
    return 0;
}


// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    w(t)
    {
    	int n;
    	cin>>n;
    	int a[n];
    	fr(i,1,n)
    		cin>>a[i];
    	sort(a,a+n);
    	int b[n];
        fr(i,1,n)
            b[i] = i;
        int j;
        int count=  1;
    	for(j = 1;j<=n;j++)
    	{
    		if(b[j] < a[j])
            {
                break;
            }
            else
                count++;
    	}
        int rem = 0;
        while(a[j] != b[j])
        {
            rem++;
            j++;
        }
        if(rem > n-j+1)
            cout<<count<<endl;
        else
        {
            rem +=1;
            int res = count + rem;
            cout<<res<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int m,n,i,j,p,q,sum=0;
    cin>>n;
    vector<long long int> a;
    for(i=0;i<n;i++)
    {
        cin>>p;
        a.push_back(p);
    }

    cin>>m;
    long long int b;
    sort(a.begin(),a.end());
    for(j=0;j<n;j++)
        {
            sum=sum+a[j];
        }
    for(i=0;i<m;i++)
    {
        cin>>b;
        q=a[n-b];
        sum=sum-q;
        //sum=sum%1000000007;
        cout<<sum<<endl;
        sum=sum+q;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,i,j,p,q,sum=0;
    cin>>n;
    vector<int> a;
    for(i=0;i<n;i++)
    {
        cin>>p;
        a.push_back(p);
    }
    cin>>m;
    int b;
    sort(a.begin(),a.end());
    for(i=0;i<m;i++)
    {
        sum=0;
        cin>>b;
        q=a[n-b];
        for(j=0;j<n;j++)
        {
            sum=sum+a[j];
        }
        sum=sum-q;
        sum=sum%1000000007;
        cout<<sum<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int m,n,i,j,p,q,sum=0;
    cin>>n;
    vector<long long int> a;
    for(i=0;i<n;i++)
    {
        cin>>p;
        a.push_back(p);
    }
    cin>>m;
    long long int b;
    sort(a.begin(),a.end());
    for(i=0;i<m;i++)
    {
        sum=0;
        cin>>b;
        q=a[n-b];
        for(j=0;j<n;j++)
        {
            sum=sum+a[j];
        }
        sum=sum-q;
        //sum=sum%1000000007;
        cout<<sum<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,i,j,p,q,sum=0;
    cin>>n;
    vector<int> a;
    for(i=0;i<n;i++)
    {
        cin>>p;
        a.push_back(p);
    }
    cin>>m;
    int b;
    sort(a.begin(),a.end());
    for(i=0;i<m;i++)
    {
        sum=0;
        cin>>b;
        q=a[n-b];
        for(j=0;j<n;j++)
        {
            sum=sum+a[j];
        }
        sum=sum-q;
        cout<<sum<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int m,n,i,j,p,q,sum=0;
    cin>>n;
    vector<int> a;
    for(i=0;i<n;i++)
    {
        cin>>p;
        a.push_back(p);
    }
    cin>>m;
    int b;
    sort(a.begin(),a.end());
    for(i=0;i<m;i++)
    {
        sum=0;
        cin>>b;
        q=a[n-b];
        for(j=0;j<n;j++)
        {
            sum=sum+a[j];
        }
        sum=sum-q;
        sum=sum%1000000007;
        cout<<sum<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define MAXN 200005
ll a[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll s = 0LL;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    sort(a,a+n);
    int m;
    cin >> m;
    for(int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        cout << s-a[n-x] << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define MAXN 200005
ll a[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll s = 0LL;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    sort(a,a+n);
    for(int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        x--;
        cout << s-a[x];
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define MAXN 200005
ll a[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll s = 0LL;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    sort(a,a+n);
    int m;
    cin >> m;
    for(int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        x--;
        cout << s-a[x];
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define MAXN 300005
ll a[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll s = 0LL;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    sort(a,a+n);
    int m;
    cin >> m;
    for(int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        cout << s-a[n-x] << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define 200005
ll a[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll s = 0LL;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    for(int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        x--;
        cout << s-a[x];
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	int sum=0;
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	sort(a,a+n);
	int m;
	cin>>m;
	int q;
	for(int i=0;i<m;i++)
	{
	    cin>>q;
	    int mini=1e5+4;
	    for(int j=0;j<n-q+1;j++)
	    {
	        mini=min(mini,sum-a[j]);
	    }
	    cout<<mini<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	int sum=0;
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	sort(a,a+n,greater<int>());
	int m;
	cin>>m;
	int q;
	for(int i=0;i<m;i++)
	{
	    cin>>q;
	    cout<<sum-a[q-1]<<endl;;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll a[n];
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	sort(a,a+n,greater<int>());
	int m;
	cin>>m;
	ll q;
	for(ll i=0;i<m;i++)
	{
	    cin>>q;
	    cout<<sum-a[q-1]<<endl;;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int sum,mini=1e5+4;
void combinationUtil(int arr[], int n, int r,
                     int index, int data[], int i);

void printCombination(int arr[], int n, int r)
{
    int data[r];

    combinationUtil(arr, n, r, 0, data, 0);
}

void combinationUtil(int arr[], int n, int r, int index,
                     int data[], int i)
{
    if (index == r) {
        for (int j = 0; j < 1; j++)
            mini=min(mini,sum-data[j]);
        return;
    }

    if (i >= n)
        return;

    data[index] = arr[i];
    combinationUtil(arr, n, r, index + 1, data, i + 1);

    combinationUtil(arr, n, r, index, data, i + 1);
}

int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	sort(a,a+n);
	int m;
	cin>>m;
	int q;
	for(int i=0;i<m;i++)
	{
	    cin>>q;
	    printCombination(a, n, q);
	    cout<<mini<<endl;
	    mini=1e5+4;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll a[n];
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	sort(a,a+n);
	ll m;
	cin>>m;
	int q;
	for(ll i=0;i<m;i++)
	{
	    cin>>q;
	    ll mini=INT_MAX;
	    for(ll j=0;j<n-q+1;j++)
	    {
	        mini=min(mini,sum-a[j]);
	    }
	    cout<<mini<<endl;
	}
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	long long n, m, somma = 0, coupon, a[300001];

	cin.tie(0);
	cin.sync_with_stdio(0);
	cout.tie(0);
	cin >> n;
	for (int i=0;i<n;i++) {
		cin >> a[i];
		somma += a[i];
	}
	sort(a,a+n, greater <int>());
	cin >> m;
	for (int i=1;i<=m;i++) {
		cin >> coupon;
		cout << somma - a[coupon -1] << endl;
	}
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	long long n, m, somma = 0, coupon, a[300001];

	cin.tie(0);
	cin.sync_with_stdio(0);
	cout.tie(0);
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		somma += a[i];
	}
	sort(a,a+n, greater <int>());
	scanf("%d",&m);
	for (int i=1;i<=m;i++) {
		scanf("%d", &coupon);
		printf("%d\n",somma - a[coupon -1]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	long long n, m, somma = 0, coupon, a[300001];

	cin.tie(0);
	cin.sync_with_stdio(0);
	cout.tie(0);
	scanf("%ld",&n);
	for (int i=0;i<n;i++) {
		scanf("%ld",&a[i]);
		somma += a[i];
	}
	sort(a,a+n, greater <int>());
	scanf("%ld",&m);
	for (int i=1;i<=m;i++) {
		scanf("%ld", &coupon);
		printf("%ld\n",somma - a[coupon -1]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n, m, somma = 0, coupon, a[300001];

	cin.tie(0);
	cin.sync_with_stdio(0);
	cout.tie(0);
	cin >> n;
	for (int i=0;i<n;i++) {
		cin >> a[i];
		somma += a[i];
	}
	sort(a,a+n, greater <int>());
	cin >> m;
	for (int i=1;i<=m;i++) {
		cin >> coupon;
		cout << somma - a[coupon -1] << endl;
	}
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n, m, somma = 0, coupon, a[300001];

	cin.tie(0);
	cin.sync_with_stdio(0);
	cout.tie(0);
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		somma += a[i];
	}
	sort(a,a+n, greater <int>());
	scanf("%d",&m);
	for (int i=1;i<=m;i++) {
		scanf("%d", &coupon);
		printf("%d\n",somma - a[coupon -1]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n, m, somma = 0, coupon, a[300001];

	cin.tie(0);
	cin.sync_with_stdio(0);
	cout.tie(0);
	scanf("%ld",&n);
	for (int i=0;i<n;i++) {
		scanf("%ld",&a[i]);
		somma += a[i];
	}
	sort(a,a+n, greater <int>());
	scanf("%d",&m);
	for (int i=1;i<=m;i++) {
		scanf("%ld", &coupon);
		printf("%ld\n",somma - a[coupon -1]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>

double a[400000];

using namespace std;

int main()
{
    int n,m;
    double tot = 0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        tot += a[i];
    }
    cin >> m;
    sort(a, a+n);
    for(int i=0;i<m;i++)
    {
        int x;
        cin >> x;
        cout << (long)tot-a[n-x] << endl;
    }

    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>

using namespace std;

vector<long> a;

int main()
{
    long n, q;
    cin >> n;
    long x;
    long summ = 0;
    for(int i=0;i<n;i++)
    {
      cin >> x;
      a.push_back(x);
      summ += x;
    }
    sort(a.begin(), a.end());

    vector<long > vv;
    cin >> q;
    for(int i=0;i<q;i++)
    {
      cin >> x;
      vv.push_back(x);
    }

    for(long i: vv)
      cout << summ - a[n-i] << endl;

    return 0;

}


#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>

using namespace std;

vector<long> a;

int main()
{
    long n, q;

    cin >> n;
    int x;
    long summ = 0;
    for(int i=0;i<n;i++)
    {
      cin >> x;
      a.push_back(x);
      summ += x;
    }

    sort(a.begin(), a.end());
    cin >> q;
    for(int i=0;i<q;i++)
    {
      cin >> x;
      cout << summ - a[n-x] << endl;
    }

    return 0;

}


#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>

using namespace std;

vector<long> a;

int main()
{
    long n, q;
    cin >> n;
    int x;
    long summ = 0;
    for(int i=0;i<n;i++)
    {
      cin >> x;
      a.push_back(x);
      summ += x;
    }
    sort(a.begin(), a.end());

    vector<int > vv;
    cin >> q;
    for(int i=0;i<q;i++)
    {
      cin >> x;
      vv.push_back(x);
    }

    for(int i: vv)
      cout << summ - a[n-i] << endl;

    return 0;

}


#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>

using namespace std;

long a[300005];
long c[300005];

int main()
{
    long n, q;

    cin >> n;
    long summ = 0;
    for(int i=0;i<n;i++)
    {
      cin >> a[i];
      summ += a[i];
    }

    sort(a, a+n);
    cin >> q;
    for(int i=0;i<q;i++)
    {
      cin >> c[i];
      cout << summ - a[n-c[i]] << endl;
    }

    return 0;

}


 #include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>

using namespace std;

vector<long long> a;

int main()
{
    long long n, q;
    cin >> n;
    long long x;
    long long summ = 0;
    for(int i=0;i<n;i++)
    {
      cin >> x;
      a.push_back(x);
      summ += x;
    }
    sort(a.begin(), a.end());

    vector<long long > vv;
    cin >> q;
    for(int i=0;i<q;i++)
    {
      cin >> x;
      vv.push_back(x);
    }

    for(long long i: vv)
      cout << summ - a[n-i] << endl;

    return 0;

}


#include <iostream>
#include <algorithm>

long a[400000];

using namespace std;

int main()
{
    int n,m;
    double tot = 0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(int i=0;i<n;i++)
    {
        tot += (double)a[i];
    }
    cin >> m;
    sort(a, a+n);
    for(int i=0;i<m;i++)
    {
        int x;
        cin >> x;
        cout << (long)tot-a[n-x] << endl;
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <stdio.h>

double a[400000];

using namespace std;

int main()
{
    int n,m;
    double tot = 0;
    scanf("%d ", &n);

    for(int i=0;i<n;i++)
    {
        scanf("%lf", &a[i]);
        tot += a[i];
    }
    scanf("%d ", &m);
    sort(a, a+n);
    for(int i=0;i<m;i++)
    {
        int x;
        cin >> x;
        printf("%ld \n", (long)(tot-a[n-x]));

    }

    return 0;
}


#include <iostream>
#include <algorithm>

long a[400000];

using namespace std;

int main()
{
    int n,m;
    long tot = 0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        tot += a[i];
    }
    cin >> m;
    sort(a, a+n);
    for(int i=0;i<m;i++)
    {
        int x;
        cin >> x;
        cout << tot-a[n-x] << endl;
    }

    return 0;
}


#include <iostream>
#include <algorithm>

long a[400000];

using namespace std;

int main()
{
    int n,m;
    long tot = 0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        tot += a[i];
    }
    cin >> m;
    sort(a, a+n);
    for(int i=0;i<m;i++)
    {
        int x;
        cin >> x;
        cout << tot-a[n-x] << endl;
    }

    return 0;
}

    cin >> m;
    sort(a, a+n);
    for(int i=0;i<m;i++)
    {
        int x;
        cin >> x;
        cout << tot-a[n-x] << endl;
    }

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int s;

int main()
{
    int n,m,a[100001],b,q,i,j;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
            s+=a[i];
        }
    cin>>m;
    sort(a+1,a+n+1,greater<int>());
    for(i=1;i<=m;i++)
        {
            cin>>q;
            cout<<s-a[q]<<' ';
        }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,a[300001],i,q;
    cin>>n;
    long long s=0;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
            s+=a[i];
        }
    sort(a+1,a+n+1,greater<int>());
    cin>>m;
    for(i=1;i<=m;i++)
        {
            cin>>q;
            cout<<s-a[q]<<endl;
        }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int s;

int main()
{
    int n,m,a[100001],b,q,i,j;
    cin>>n;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
            s+=a[i];
        }
    cin>>m;
    sort(a+1,a+n+1,greater<int>());
    for(i=1;i<=m;i++)
        {
            cin>>q;
            cout<<s-a[q]<<endl;
        }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int s;

int main()
{
    int n,m,a[100001],b,q,i,j;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
            s+=a[i];
        }
    cin>>m;
    sort(a+1,a+n+1,greater<int>());
    for(i=1;i<=n;i++)
        {
            cin>>q;
            cout<<s-a[q]<<' ';
        }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int s;

int main()
{
    int n,m,a[100001],b,q,i,j;
    cin>>n;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
            s+=a[i];
        }
    sort(a+1,a+n+1,greater<int>());
    cin>>m;
    for(i=1;i<=m;i++)
        {
            cin>>q;
            cout<<s-a[q]<<endl;
        }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,m,a[300001],s=0,i,q;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
            s+=a[i];
        }
    sort(a+1,a+n+1,greater<int>());
    cin>>m;
    for(i=1;i<=m;i++)
        {
            cin>>q;
            cout<<s-a[q]<<endl;
        }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int s[100001];

int main()
{
    int n,m,a[100001],b,q[100000],i,j;
    cin>>n;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
        }
    cin>>m;
    for(i=1;i<=m;i++)
        cin>>q[i];
    sort(a+1,a+n+1);
    for(i=1;i<=m;i++)
    {
        b=a[n-q[i]];
        a[n-q[i]]=0;
        for(j=1;j<=n;j++)
        s[i]+=a[j];
        a[n-q[i]]=b;
    }
    for(i=1;i<=m;i++)
        cout<<s[i]<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int main()
{
	int N, M;
	cin >> N;
	int *p = new int[N];
	long long *sum = new long long[N];
	for(int i = 0; i < N; ++i)
	{
		cin >> p[i];
		if(i == 0)
			sum[i] = p[i];
		else
			sum[i] = sum[i-1] + p[i];
	}
	sort(p, p + N);
	cin >> M;

	long long ans = INT_MAX;

	for(int i = 0; i < M; ++i)
	{
		int m;
		cin >> m;
		long long temp = sum[N-1] - p[N-m];
		if(temp < ans)
			ans = temp;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int main()
{
	int N, M;
	cin >> N;
	int *p = new int[N];
	long long *sum = new long long[N];
	for(int i = 0; i < N; ++i)
	{
		cin >> p[i];
		if(i == 0)
			sum[i] = p[i];
		else
			sum[i] = sum[i-1] + p[i];
	}
	sort(p, p + N);
	cin >> M;

	for(int i = 0; i < M; ++i)
	{
		int m;
		cin >> m;
		long long temp = sum[N-1] - p[N-m];
		cout << temp << endl;
	}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int N, M;
	cin >> N;
	int *p = new int[N];
	long long *sum = new long long[N];
	for(int i = 0; i < N; ++i)
	{
		cin >> p[i];
		if(i == 0)
			sum[i] = p[i];
		else
			sum[i] = sum[i-1] + p[i];
	}
	sort(p, p + N);
	cin >> M;

	long long ans = 0;

	for(int i = 0; i < M; ++i)
	{
		int m;
		cin >> m;
		long long temp = sum[N-1] + p[N-m]
		if(temp < ans)
			ans = temp;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int main()
{
	int N, M;
	cin >> N;
	int *p = new int[N];
	long long *sum = new long long[N];
	for(int i = 0; i < N; ++i)
	{
		cin >> p[i];
		if(i == 0)
			sum[i] = p[i];
		else
			sum[i] = sum[i-1] + p[i];
	}
	sort(p, p + N);
	cin >> M;

	long long ans = INT_MAX;

	for(int i = 0; i < M; ++i)
	{
		int m;
		cin >> m;
		long long temp = sum[N-1] + p[N-m];
		if(temp < ans)
			ans = temp;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int N, M;
	cin >> N;
	int *p = new int[N];
	long long *sum = new long long[N];
	for(int i = 0; i < N; ++i)
	{
		cin >> p[i];
		if(i == 0)
			sum[i] = p[i];
		else
			sum[i] = sum[i-1] + p[i];
	}
	sort(p, p + N);
	cin >> M;

	long long ans = 0;

	for(int i = 0; i < M; ++i)
	{
		int m;
		cin >> m;
		long long temp = sum[N-1] + p[N-m];
		if(temp < ans)
			ans = temp;
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 long n;
 cin >> n;
 int a[3000100];
 long long suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 long q[n + 1000];
 long long sumos[n + 1000];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     cout << suma - a[n - q[i]] << endl;
 }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 long n;
 cin >> n;
 int a[100010];
 int suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 long q[n + 10];
 long long sumos[n + 10];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     cout << suma - a[n - q[i]] << endl;
 }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 long n;
 cin >> n;
 int a[100010];
 int suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 long q[n];
 long long sumos[n + 10];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     cout << suma - a[n - q[i]] << endl;
 }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin >> n;
 long long a[100010];
 long long suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 int q[n + 1];
 long long sumos[n + 10];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     sumos[i] = suma - a[n - q[i]];
     cout << sumos[i] << endl;

 }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 long n;
 cin >> n;
 int a[300010];
 int suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 long q[n + 10];
 long long sumos[n + 10];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     cout << suma - a[n - q[i]] << endl;
 }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 long n;
 cin >> n;
 int a[3000100];
 int suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 long q[n + 10];
 long long sumos[n + 10];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     cout << suma - a[n - q[i]] << endl;
 }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin >> n;
 long long a[100010];
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
 }
 int k;
 cin >> k;
 int q[n + 1];
 long long suma = 0;
 long long sumos[n + 10];
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     sumos[i] = 0;
 }
 sort(a, a + n);
 for(int i = 0; i < n; i++)
 {
        suma+=a[i];
 }
 for(int i = 0;  i < k; i ++)
 {
     sumos[i] = suma - a[n - q[i]];
 }
for(int i = 0; i < k; i++)
{
    cout << sumos[i] << endl;
}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 long n;
 cin >> n;
 long long a[100010];
 long long suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 long q[n + 10];
 long long sumos[n + 10];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     cout << suma - a[n - q[i]] << endl;
 }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin >> n;
 long long a[100010];
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
 }
 int k;
 cin >> k;
 int q[n + 1];
 long long suma[k + 10];
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     suma[i] = 0;
 }
 sort(a, a + n);
 for(int j = 0; j < k; j++)
{
 for(int i = 0; i < n; i++)
 {
    if(i != n - q[j])
    {
        suma[j]+=a[i];
    }
 }
}
for(int i = 0; i < k; i++)
{
    cout << suma[i] << endl;
}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin >> n;
 long long a[100010];
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
 }
 int k;
 cin >> k;
 int q[n + 1];
 long long suma = 0;
 long long sumos[n + 10];
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     sumos[i] = 0;
 }
 sort(a, a + n);
 for(int i = 0; i < n; i++)
 {
        suma+=a[i];
 }
 for(int i = 0;  i < k; i ++)
 {
     sumos[i] = suma - a[n - q[i]];
 }
for(int i = 0; i < k; i++)
   {
    cout << sumos[i] << endl;
   }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 long n;
 cin >> n;
 if(n > 30010) return 0;
 int a[300010];
 int suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 long q[n + 10];
 long long sumos[n + 10];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     cout << suma - a[n - q[i]] << endl;
 }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin >> n;
 int a[10000];
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
 }
 int k;
 cin >> k;
 int q[n + 1];
  int suma[k + 10];
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     suma[i] = 0;
 }
 sort(a, a + n);
 for(int j = 0; j < k; j++)
{
 for(int i = 0; i < n; i++)
 {
    if(i != n - q[j])
    {
        suma[j]+=a[i];
    }
 }
}
for(int i = 0; i < k; i++)
{
    cout << suma[i] << endl;
}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin >> n;
 long long a[100010];
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
 }
 int k;
 cin >> k;
 int q[n + 1];
 long long suma = 0;
 long long sumos[n + 10];
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     sumos[i] = 0;
 }
 sort(a, a + n);
 for(int i = 0; i < n; i++)
 {
        suma+=a[i];
 }
 for(int i = 0;  i < k; i ++)
 {
     sumos[i] = suma - a[n - q[i]];
 }
for(int i = 0; i < k; i++)
 {
    cout << sumos[i] << endl;
 }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin >> n;
 long long a[100010];
 long long suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 int q[n + 1];
 long long sumos[n + 10];
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     sumos[i] = 0;
 }
 sort(a, a + n);
 for(int i = 0;  i < k; i ++)
 {
     sumos[i] = suma - a[n - q[i]];
 }
for(int i = 0; i < k; i++)
{
    cout << sumos[i] << endl;
}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 long n;
 cin >> n;
 int a[3000100];
 int suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 long q[n + 1000];
 long long sumos[n + 1000];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     cout << suma - a[n - q[i]] << endl;
 }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin >> n;
 long long a[100010];
 long long suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 int q[n + 1];
 long long sumos[n + 10];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
      sumos[i] = suma - a[n - q[i]];

 }
for(int i = 0; i < k; i++)
{
    cout << sumos[i] << endl;
}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
 long n;
 cin >> n;
 long a[100010];
 long suma = 0;
 for(int i = 0; i < n; i++)
 {
     cin >> a[i];
     suma += a[i];
 }
 int k;
 cin >> k;
 long q[n + 10];
 long long sumos[n + 10];
  sort(a, a + n);
 for(int i = 0; i < k; i++)
 {
     cin >> q[i];
     cout << suma - a[n - q[i]] << endl;
 }
}


#include <bits/stdc++.h>
using namespace std;

#define lll __int64
#define ll long long
#define ar array

const int mxN=2e5;
int n, a[mxN], k;

void solve() {
	//implentation goes here
    ll n;
    cin>>n;
    vector<ll> arr(n);
    for(int i = 0 ; i  < n ; ++i){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    ll m;
    cin>>m;
    for(int i = 0 ; i  < m ;++i){
        ll a;
        cin>>a;
        ll temp = accumulate(arr.begin() + (n-a) + 1,arr.end(),0);
        //cout<<temp<<" ";
        temp += accumulate(arr.begin(),arr.begin() + (n-a) , 0);
        //cout<<temp<<endl;
        cout<<temp<<endl;
    }

}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	solve();
}


#include <bits/stdc++.h>
using namespace std;

#define lll __int64
#define ll long long
#define ar array

const int mxN=2e5;
int n, a[mxN], k;
long long res[mxN];
void solve() {
	//implentation goes here
    long long sum = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", a + i);
		sum += a[i];
	}
	sort(a, a + n);

	memset(res, -1, sizeof res);
	int m;
	scanf("%d", &m);
	for(int i = 0; i < m; ++i){
		int c;
		scanf("%d", &c);
		if(res[c] == -1){
			res[c] = sum - a[n - c];
		}

		printf("%lld\n", res[c]);
	}

}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	solve();
}


#include <bits/stdc++.h>

using namespace std;

const int N = 300009;

int n;
int a[N];
long long res[N];

int main() {
	long long sum = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", a + i);
		sum += a[i];
	}
	sort(a, a + n);

	memset(res, -1, sizeof res);
	int m;
	scanf("%d", &m);
	for(int i = 0; i < m; ++i){
		int c;
		scanf("%d", &c);
		if(res[c] == -1){
			res[c] = sum - a[n - c];
		}

		printf("%lld\n", res[c]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define lll __int64
#define ll long long
#define ar array

const int mxN=2e5;
int n, a[mxN], k;

void solve() {
	//implentation goes here
    ll n;
    cin>>n;
    vector<ll> arr(n);
    for(int i = 0 ; i  < n ; ++i){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    ll m;
    cin>>m;
    vector<ll> res;
    for(int i = 0 ; i  < m ;++i){
        ll a;
        cin>>a;
        ll temp = accumulate(arr.begin() + (n-a) + 1,arr.end(),0);
        //cout<<temp<<" ";
        temp += accumulate(arr.begin(),arr.begin() + (n-a) , 0);
        //cout<<temp<<endl;
        res.push_back(temp);
    }
    for(int i = 0 ; i < m ; ++i){
        cout<<res[i]<<endl;
    }

}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	solve();
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long n, m, sum{0}, t;
    cin >> n; long a[n];
    for(long i = 0; i < n; ++i) {cin >> a[i]; sum += a[i];}
    sort(a, a + n);
    cin >> m;
    for(long i = 0; i < m; ++i) {cin >> t; cout << sum - a[n - t] << endl;}
    return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long n, m, t;
    long long sum{0};
    cin >> n; long a[n];
    for(long i = 0; i < n; ++i) {cin >> a[i]; sum += a[i];}
    sort(a, a + n);
    cin >> m;
    for(long i = 0; i < m; ++i) {cin >> t; cout << sum - a[n - t] << endl;}
    return 0;

}


#include <bits/stdc++.h>

using namespace std;

long main()
{
    long n, m, sum{0}, t;
    cin >> n; long a[n];
    for(long i = 0; i < n; ++i) {cin >> a[i]; sum += a[i];}
    sort(a, a + n);
    cin >> m;
    for(long i = 0; i < m; ++i) {cin >> t; cout << sum - a[n - t] << endl;}

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long n, m, sum{0}, t;
    cin >> n; long a[n];
    for(long i = 0; i < n; ++i) {cin >> a[i]; sum += a[i];}
    sort(a, a + n);
    cin >> m;
    for(long i = 0; i < m; ++i) {cin >> t; cout << sum - a[n - t] << endl;}

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m, sum{0}, t;
    cin >> n; int a[n];
    for(int i = 0; i < n; ++i) {cin >> a[i]; sum += a[i];}
    sort(a, a + n);
    cin >> m;
    for(int i = 0; i < m; ++i) {cin >> t; cout << sum - a[n - t] << endl;}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rr register int
#define ii int
#define mp make_pair
#define cl(myvector) vector<ll>().swap(myvector)
#define debug(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define MAX 800000
#define fastread ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

ll a[MAX],q[MAX];
int main(){
	fastread;
	ll n;
	cin>>n;
	for(ii i=0;i<n;i++){
		cin>>a[i];
	}

	int m;
	cin>>m;

	for(ii i=0;i<m;i++){
		cin>>q[i];

	}
	sort(a,a+n);

	reverse(a,a+n);
	//sort(q,q+m);
	ll sum=0;
	for(ii i=0;i<n;i++){
		sum+=a[i];
		//debug(prefix[i]);
	}
	ll ans=0;
	for(ii i=0;i<m;i++){
		ans=sum - a[q[i]-1];
		cout<<ans<<"\n";
	}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rr register int
#define ii int
#define mp make_pair
#define cl(myvector) vector<ll>().swap(myvector)
#define debug(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define MAX 800000
#define fastread ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
vector<ll>G[MAX];
bool visited[MAX];
ll a[MAX],prefix[MAX],q[MAX];
int main(){
	fastread;
	ll n;
	cin>>n;
	for(ii i=0;i<n;i++){
		cin>>a[i];
	}

	ll m;
	cin>>m;

	for(ii i=0;i<m;i++){
		cin>>q[i];
		debug(q[i]);
	}
	sort(a,a+n);

	reverse(a,a+n);
	//sort(q,q+m);
	ll sum=0;
	for(ii i=0;i<n;i++){
		sum+=a[i];
		//debug(prefix[i]);
	}
	ll ans=0;
	for(ii i=0;i<m;i++){
		cout<<sum - a[q[i]-1]<<"\n";
	}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rr register int
#define ii int
#define mp make_pair
#define cl(myvector) vector<ll>().swap(myvector)
#define debug(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define MAX 800000
#define fastread ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
vector<ll>G[MAX];
bool visited[MAX];
ll a[MAX],prefix[MAX],q[MAX];
int main(){
	//fastread
	ll n;
	cin>>n;
	for(ii i=0;i<n;i++){
		cin>>a[i];
	}

	ll m;
	cin>>m;

	for(ii i=0;i<m;i++){
		cin>>q[i];
		debug(q[i]);
	}
	sort(a,a+n);

	reverse(a,a+n);
	sort(q,q+m);
	for(ii i=0;i<n;i++){
		prefix[i]=prefix[i-1]+a[i];
		//debug(prefix[i]);
	}
	ll ans=0;
	for(ii i=0;i<m;i++){
		cout<<prefix[n-1] - a[q[i]-1]<<"\n";
	}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rr register int
#define ii int
#define mp make_pair
#define cl(myvector) vector<ll>().swap(myvector)
#define debug(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define MAX 800000
#define fastread ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
vector<ll>G[MAX];
bool visited[MAX];
ll a[MAX],prefix[MAX],q[MAX];
int main(){
	//fastread
	ll n;
	cin>>n;
	for(ii i=0;i<n;i++){
		cin>>a[i];
	}

	ll m;
	cin>>m;

	for(ii i=0;i<m;i++){
		cin>>q[i];
		debug(q[i]);
	}
	sort(a,a+n);

	reverse(a,a+n);
	sort(q,q+m);
	for(ii i=0;i<n;i++){
		prefix[i]=prefix[i-1]+a[i];
		//debug(prefix[i]);
	}
	ll ans=0;
	for(ii i=0;i<m;i++){
		debug(q[i]-1);
		debug(prefix[q[i]-1]);
		ans=(prefix[q[i] -1] - a[q[i] -1]);
		debug(ans);
		ans+= (prefix[n-1] - prefix[q[i]-1]);
		cout<<ans<<"\n";
		ans=0;
	}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rr register int
#define ii int
#define mp make_pair
#define cl(myvector) vector<ll>().swap(myvector)
#define debug(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define MAX 800000
#define fastread ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
vector<ll>G[MAX];
bool visited[MAX];
ll a[MAX],prefix[MAX],q[MAX];
int main(){
	//fastread
	ll n;
	cin>>n;
	for(ii i=0;i<n;i++){
		cin>>a[i];
	}

	ll m;
	cin>>m;

	for(ii i=0;i<m;i++){
		cin>>q[i];
		debug(q[i]);
	}
	sort(a,a+n);

	reverse(a,a+n);
	//sort(q,q+m);
	for(ii i=0;i<n;i++){
		prefix[i]=prefix[i-1]+a[i];
		//debug(prefix[i]);
	}
	ll ans=0;
	for(ii i=0;i<m;i++){
		cout<<prefix[n-1] - a[q[i]-1]<<"\n";
	}

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define unsigned long long
ll n,m,l;
ll s1,s2;

int main()
{
	cin >> n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
	         cin >> a[i];
	         s1+=a[i];
	}
	cin >> m;

	ll b[m];
	ll p;
	for(int i=0;i<m;i++)
	{
	         cin >> b[i];
	}
	sort(a,a+n);
	for(int i=0;i<m;i++)
	{
	     p = n-b[i];
	     p = s1-a[p];

	     cout << p << endl;
	}

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define unsigned long long
ll n,m,l,s1,s2;

int main()
{
	cin >> n;
	ll a[n];
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		s1+=a[i];
	}
	cin >> m;
	int b[m],q[m];
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(a[i] < a[j])
			{
				int r = a[i];
				a[i] = a[j];
				a[j] = r;
			}
		}
	}
	for(int i=1;i<=m;i++)
	{
		cin >> b[i];
	}
	s2 = s1;
	for(int i=1;i<=m;i++)
	{
		q[i] = s1-a[b[i]];
	}

	for(int i=1;i<=m;i++)
	cout << q[i] << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define unsigned long long
int n,m,l;
ll s1,s2;

int main()
{
	cin >> n;
	int a[n];
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		s1+=a[i];
	}
	cin >> m ;
	int b[m],q[m];

	sort(a,a+n);

	for(int i=1;i<=m;i++)
	{
		cin >> b[i];
		int p = b[i];
		q[i] = (s1-a[n-p]);
	}

	sort(q,q+m);
	for(int i=1;i<=m;i++)
	cout << q[i] << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define unsigned long long
int n,m,l;
ll s1,s2;

int main()
{
	cin >> n;
	int a[n];
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		s1+=a[i];
	}
	cin >> m ;
	int b[m],q[m];

	sort(a,a+n);

	for(int i=1;i<=m;i++)
	{
		cin >> b[i];
	}
	s2 = s1;
	for(int i=1;i<=m;i++)
	{
		q[i] = s1-a[n-(b[i]-1)];
	}

	for(int i=1;i<=m;i++)
	cout << q[i] << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define unsigned long long
int n,m,l;
ll s1,s2;

int main()
{
	cin >> n;
	int a[n];
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		s1+=a[i];
	}
	cin >> m ;
	int b[m],q[m];

	sort(a,a+n);

	for(int i=1;i<=m;i++)
	{
		cin >> b[i];
	}

	for(int i=1;i<=m;i++)
	{
	         int p = b[i];
		q[i] = s1-a[n-p];
	}

	for(int i=1;i<=m;i++)
	cout << q[i] << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define unsigned long long
int n,m,l;
ll s1,s2;

int main()
{
	cin >> n;
	int a[n];
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		s1+=a[i];
	}
	cin >> m ;
	int b[m],q[m];

	sort(a,a+n);

	for(int i=1;i<=m;i++)
	{
		cin >> b[i];
		int p = b[i];
		q[i] = (s1-a[n-p]);
	}

	for(int i=1;i<=m;i++)
	cout << q[i] << endl;
	return 0;
}


#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int cnt,sum,s,a[n],b[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		b[i]=a[i];
		sum=sum+a[i];
	}
	s=sum;
	sort(b,b+n,greater<int>());
	int m;
	cin >> m;
	int q[m];
	for(int i=0;i<m;i++)
	{
		cin >> q[i];
	}
	for(int j=0;j<m;j++)
	{
		sum=s;
		cnt=q[j]-1;
		sum=sum-b[cnt];
		cout << sum << endl;
	}

}


#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	long long int n;
	cin >> n;
	long long int cnt,sum,s,a[n],b[n];
	for(long long int i=0;i<n;i++)
	{
		cin >> a[i];
		b[i]=a[i];
		sum=sum+a[i];
	}
	s=sum;
//	cout << "this is s " << s << endl;
	sort(b,b+n,greater<int>());
	long long int m;
	cin >> m;
	long long int q[m];
	//for(int i=0;i<m;i++)

	for(long long int j=0;j<m;j++)
	{
		sum=s;
		cin >> q[j];
	//	cnt=q[j]-1;
		sum=sum-b[q[j]-1];
		cout << sum << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,sum=0,temp;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		sum+=a[i];
	}
	temp=sum;
	sort(a,a+n,greater<int>());
	int m;
	cin >> m;
	int q[m];
	for(int i=0;i<m;i++)
	{
		cin >> q[i];
		k=q[i];
		sum=sum-a[k-1];
		cout << sum << endl;
		sum=temp;
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll int n,k,sum=0,temp;
	cin >> n;
	ll int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		sum+=a[i];
	}
	temp=sum;
	sort(a,a+n,greater<int>());
	ll int m;
	cin >> m;
	ll int q[m];
	for(int i=0;i<m;i++)
	{
		cin >> q[i];
		k=q[i];
		sum=sum-a[k-1];
		cout << sum << endl;
		sum=temp;
	}
}


#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int sum,a[n],b[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		b[i]=a[i];
	}
	sort(b,b+n,greater<int>());
	int m;
	cin >> m;
	int q[m];
	for(int i=0;i<m;i++)
	{
		cin >> q[i];
	}
	for(int j=0;j<m;j++)
	{	sum=0;
	for(int i=0;i<n;i++)
	{
		if(i!=(q[j]-1))
		sum=sum+b[i];
	}
	cout << sum << endl;
	}
}


#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	long int n;
	cin >> n;
	long int cnt,sum,s,a[n],b[n];
	for(long long int i=0;i<n;i++)
	{
		cin >> a[i];
		b[i]=a[i];
		sum += a[i];
	}
	s=sum;
	sort(b,b+n,greater<int>());
	long int m;
	cin >> m;
	long int q[m];

	for(long int j=0;j<m;j++)
	{
		sum=s;
		cin >> q[j];
		cnt=q[j]-1;
		sum-=b[cnt];
		cout << sum << endl;
	}
}


#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int cnt,sum,s,a[n],b[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		b[i]=a[i];
		sum=sum+a[i];
	}
	s=sum;
//	cout << "this is s " << s << endl;
	sort(b,b+n,greater<int>());
	int m;
	cin >> m;
	int q[m];
	//for(int i=0;i<m;i++)

	for(int j=0;j<m;j++)
	{
		sum=s;
		cin >> q[j];
		cnt=q[j]-1;
		sum=sum-b[cnt];
		cout << sum << endl;
	}
}


#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	long long int n;
	cin >> n;
	long long int cnt,sum,s,a[n],b[n];
	for(long long int i=0;i<n;i++)
	{
		cin >> a[i];
		b[i]=a[i];
		sum=sum+a[i];
	}
	s=sum;
//	cout << "this is s " << s << endl;
	sort(b,b+n,greater<int>());
	long long int m;
	cin >> m;
	long long int q[m];
	//for(int i=0;i<m;i++)

	for(long long int j=0;j < m;j++)
	{
		sum=s;
		cin >> q[j];
		cnt=q[j]-1;
		sum=sum-b[cnt];
		cout << sum-1 << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;

void sort(vector<long long> & bar);
void mergeSort(vector<long long>&left,vector<long long>& right,vector<long long>& bars);

int main()
{
    long long n;
    scanf("%lld",&n);
    long long m,q,i,j,x;
    vector<long long>a;
    for(i=0;i<n;i++)
    {

        cin>>x;
        a.push_back(x);
    }

    sort(a);
    vector< long long> b(a);

    for(i=1;i<b.size();i++)
    {
        b[i]=b[i]+b[i-1];
    }

    scanf("%lld",&m);
    while(m--)
    {
        scanf("%lld",&q);
        cout<<b[n-1]-a[n-q]<<endl;
    }
    return 0;
}

void sort(vector<long long> & bar) {
    if (bar.size() <= 1) return;

    long long mid = bar.size() / 2;
    vector<long long> left;
    vector<long long> right;

    for (size_t j = 0; j < mid;j++)
        left.push_back(bar[j]);
    for (size_t j = 0; j < (bar.size()) - mid; j++)
        right.push_back(bar[mid + j]);

    sort(left);
    sort(right);
    mergeSort(left, right, bar);
}
void mergeSort(vector<long long>&left, vector<long long>& right, vector<long long>& bars)
{
    long long nL = left.size();
    long long nR = right.size();
    long long i = 0, j = 0, k = 0;

    while (j < nL && k < nR)
    {
        if (left[j] < right[k]) {
            bars[i] = left[j];
            j++;
        }
        else {
            bars[i] = right[k];
            k++;
        }
        i++;
    }
    while (j < nL) {
        bars[i] = left[j];
        j++; i++;
    }
    while (k < nR) {
        bars[i] = right[k];
        k++; i++;
    }
}


#include<bits/stdc++.h>
using namespace std;

void sort(vector<int> & bar);
void mergeSort(vector<int>&left,vector<int>& right,vector<int>& bars);

int main()
{
    long long n;
    scanf("%lld",&n);
    long long m,q,i,j,x;
    vector<int>a;
    for(i=0;i<n;i++)
    {

        cin>>x;
        a.push_back(x);
    }

    sort(a);

    scanf("%lld",&m);
    while(m--)
    {
        scanf("%lld",&q);
        long long sum=0,c=0;
        for(j=n-1;j>=0;j--)
        {
            c++;
            if(c==q)
                continue;
            sum=sum+a[j];
        }
        cout<<sum<<endl;
    }
    return 0;
}

void sort(vector<int> & bar) {
    if (bar.size() <= 1) return;

    int mid = bar.size() / 2;
    vector<int> left;
    vector<int> right;

    for (size_t j = 0; j < mid;j++)
        left.push_back(bar[j]);
    for (size_t j = 0; j < (bar.size()) - mid; j++)
        right.push_back(bar[mid + j]);

    sort(left);
    sort(right);
    mergeSort(left, right, bar);
}
void mergeSort(vector<int>&left, vector<int>& right, vector<int>& bars)
{
    int nL = left.size();
    int nR = right.size();
    int i = 0, j = 0, k = 0;

    while (j < nL && k < nR)
    {
        if (left[j] < right[k]) {
            bars[i] = left[j];
            j++;
        }
        else {
            bars[i] = right[k];
            k++;
        }
        i++;
    }
    while (j < nL) {
        bars[i] = left[j];
        j++; i++;
    }
    while (k < nR) {
        bars[i] = right[k];
        k++; i++;
    }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int a[n+1],m,q;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    scanf("%d",&m);
    while(m--)
    {
        scanf("%d",&q);
        int sum=0,c=0;
        for(int j=n-1;j>=0;j--)
        {
            c++;
            if(c==q)
                continue;
            sum=sum+a[j];
        }
        cout<<sum<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

void sort(vector<int> & bar);
void mergeSort(vector<int>&left,vector<int>& right,vector<int>& bars);

int main()
{
    long long n;
    scanf("%lld",&n);
    long long m,q,i,j,x;
    vector<int>a;
    for(i=0;i<n;i++)
    {

        cin>>x;
        a.push_back(x);
    }

    sort(a);
    vector<int> b(a);

    for(i=1;i<b.size();i++)
    {
        b[i]=b[i]+b[i-1];
    }

    scanf("%lld",&m);
    while(m--)
    {
        scanf("%lld",&q);
        cout<<b[n-1]-a[n-q]<<endl;
    }
    return 0;
}

void sort(vector<int> & bar) {
    if (bar.size() <= 1) return;

    int mid = bar.size() / 2;
    vector<int> left;
    vector<int> right;

    for (size_t j = 0; j < mid;j++)
        left.push_back(bar[j]);
    for (size_t j = 0; j < (bar.size()) - mid; j++)
        right.push_back(bar[mid + j]);

    sort(left);
    sort(right);
    mergeSort(left, right, bar);
}
void mergeSort(vector<int>&left, vector<int>& right, vector<int>& bars)
{
    int nL = left.size();
    int nR = right.size();
    int i = 0, j = 0, k = 0;

    while (j < nL && k < nR)
    {
        if (left[j] < right[k]) {
            bars[i] = left[j];
            j++;
        }
        else {
            bars[i] = right[k];
            k++;
        }
        i++;
    }
    while (j < nL) {
        bars[i] = left[j];
        j++; i++;
    }
    while (k < nR) {
        bars[i] = right[k];
        k++; i++;
    }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long n;
    scanf("%lld",&n);
    long long a[n+1],m,q,i,j,b[n+1];
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);

    b[0]=a[0];
    for(i=1;i<n;i++)
    {
        b[i]=a[i]+b[i-1];
    }

    scanf("%lld",&m);
    while(m--)
    {
        scanf("%lld",&q);
        cout<<b[n-1]-a[n-q]<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long n;
    scanf("%lld",&n);
    long long a[n+1],m,q,i,j;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    scanf("%lld",&m);
    while(m--)
    {
        scanf("%lld",&q);
        long long sum=0,c=0;
        for(j=n-1;j>=0;j--)
        {
            c++;
            if(c==q)
                continue;
            sum=sum+a[j];
        }
        cout<<sum<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{

		long int n;
		cin>>n;
		long int a[n+1];
		for(int i=1;i<=n;i++)
		cin>>a[i];
		long int m;
		cin>>m;
		long int q[m+1];
		sort(a+1,a+n+1);
		reverse(a+1,a+n+1);
		for(int j=1;j<=m;j++)
		{
			cin>>q[j];
			long long int sum=0;
			for(int i=1;i<=q[j]-1;i++)
			{
				sum=sum+a[i];
			}
			for(int k=q[j]+1;k<=n;k++)
			{
				sum=sum+a[k];
			}
			cout<<sum<<endl;
		}
	}


#include<bits/stdc++.h>
using namespace std;
int main()
{

		long int n;
		cin>>n;
		long int a[n+1];
		for(int i=1;i<=n;i++)
		cin>>a[i];
		long int m;
		cin>>m;
		long int q[m+1];
		sort(a+1,a+n+1);
		reverse(a+1,a+n+1);
		for(int j=1;j<=m;j++)
		{
			cin>>q[j];
			long long int sum=0;
			for(int i=1;i<=q[j]-1;i++)
			{
				sum=sum+a[i];
			}
			for(int k=q[j]+1;k<=n;k++)
			{
				sum=sum+a[k];
			}
			cout<<sum<<endl;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
		long long int n;
		cin>>n;
		long long int a[n+1];
		for(int i=1;i<=n;i++)
		cin>>a[i];
		long long int m;
		cin>>m;
		long long int q[m+1];
		sort(a+1,a+n+1);
		reverse(a+1,a+n+1);
		 long long int pre[n+1];
		 pre[1]=a[1];
		for(int i=2;i<=n;i++)
		{
			pre[i]=a[i]+pre[i-1];
		}
		for(int i=1;i<=m;i++)
		{
			cin>>q[i];
			long long int sum=0;
			sum=sum+pre[q[i]-1];
			sum=sum+pre[n]-pre[q[i]];
			cout<<sum<<endl;
		}
	}


#include<bits/stdc++.h>
using namespace std;
int main()
{
		long int n;
		cin>>n;
		long long int a[n+1];
		for(int i=1;i<=n;i++)
		cin>>a[i];
		long long int m;
		cin>>m;
		long long int q[m+1];
		sort(a+1,a+n+1);
		reverse(a+1,a+n+1);
		 long int pre[n+1];
		 pre[1]=a[1];
		for(int i=2;i<=n;i++)
		{
			pre[i]=a[i]+pre[i-1];
		}
		for(int i=1;i<=m;i++)
		{
			cin>>q[i];
			long long int sum=0;
			sum=sum+pre[q[i]-1];
			sum=sum+pre[n]-pre[q[i]];
			cout<<sum<<endl;
		}
	}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long int n;
    cin>>n;
    long long int a[n];
    long long int sum=0;
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    sort(a,a+n,greater<int>());

    long long int m;
    cin>>m;
    long long int b[m];
    for(long long int i=0;i<m;i++)
    {
        cin>>b[i];
        cout<<sum-a[b[i]-1]<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m,count=0;
    string k;
    cin>>n>>m;
    vector <string> v;
    for(int i=0;i<n;i++){
        cin>>k;
        if(!v.empty()) if(k.compare(v[0])==0) count=-1;
        v.push_back(k);
    }
    vector <int> sum(m,0);
    for(int j=0;j<m;j++){
        for(int i=0;i<n;i++){
            sum[j] += int(v[i][j])-48;
        }
    }
    sort(sum.begin(),sum.end());
    if(count==0){
        if(sum[0]==sum[sum.size()-1]) cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main() {
    int l,w;
    cin >> l >> w;
    int adjacent = -1;
    for(int i = 0; i < l; i++) {
        int previous = -1;
        int b;
        cin >> b;
        for(int n = 0; n < w; n++) {
            int a = b % 10;
            b %= 10;
            if (b > 9 || b < 0) {
                cout << "NO";
                    return 0;
            }
            if (previous == -1) {
                if (adjacent == a) {
                    cout << "NO";
                    return 0;
                }
                previous = a;
            } else if (previous != a) {
                cout << "NO";
                return 0;
            }
        }
        adjacent = previous;
    }
    cout << "YES";
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main() {
    int l,w;
    cin >> l >> w;
    char adjacent = 'A';
    for(int i = 0; i < l; i++) {
        char previous = 'A';
        string a;
        cin >> a;
        for(int n = 0; n < w; n++) {
            if (previous == 'A') {
                if (adjacent == a[n]) {
                    cout << "NO";
                    return 0;
                }
                previous = a[n];
            } else if (previous != a[n]) {
                cout << "NO";
                return 0;
            } else {

            }
        }
        adjacent = previous;
    }
    cout << "YES";
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main() {
    int l,w;
    cin >> l >> w;
    int adjacent = INFINITY;
    for(int i = 0; i < l; i++) {
        int previous = INFINITY;
        int b;
        cin >> b;
        for(int n = 0; n < w; n++) {
            int a = b % 10;
            b %= 10;
            if (b > 9 || b < 0) {
                cout << "NO";
                    return 0;
            }
            if (previous == INFINITY) {
                if (adjacent == a) {
                    cout << "NO";
                    return 0;
                }
                previous = a;
            } else if (previous != a) {
                cout << "NO";
                return 0;
            }
        }
        adjacent = previous;
    }
    cout << "YES";
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main() {
    int l,w;
    cin >> l >> w;
    int adjacent = -1;
    for(int i = 0; i < l; i++) {
        int previous = -1;
        int b;
        cin >> b;
        for(int n = 0; n < w; n++) {
            int a = b % 10;
            int first = (int)trunc((2 / pow(10, 3 - 1)));
            cout << first;
            b %= 10;
            if (a > 9 || a < 0) {
                cout << "NO";
                return 0;
            }
            if (previous == -1) {
                if (adjacent == a) {
                    cout << "NO";
                    return 0;
                }
                previous = a;
            } else if (previous != a) {
                cout << "NO";
                return 0;
            } else {

            }
        }
        adjacent = previous;
    }
    cout << "YES";
    return 0;
}


#include <bits/stdc++.h>++
        typedef long long int ll;

    using namespace std;

    int main()
    {
        ios_base::sync_with_stdio(false);
          cin.tie(NULL);
        ll n,m,flag=0;
        cin>>n>>m;
        char a[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }
set<char,greater<char> > x;
        for(int i=0;i<n;i++)
        {
            x.insert(a[i][0]);
        }
        if(x.size()!=n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        flag=0;
        if(n==m && n==1)
            cout<<"YES"<<endl;
        else{
        for(int i=0;i<n;i++)
        {flag=0;
            for(int j=0;j<m-1;j++)
            {
                if(a[i][j]==a[i][j+1] &&a[i][j]==a[i][0])
                    flag=1;
                else{
                    flag=0;
                break;}
            }
            if(flag==0)
                break;
        }
        if(flag==0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;}
        return 0;

    }


#include <bits/stdc++.h>++
        typedef long long int ll;

    using namespace std;

    int main()
    {
        ios_base::sync_with_stdio(false);
          cin.tie(NULL);
        ll n,m,flag=0;
        cin>>n>>m;
        char a[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }
set<char,greater<char> > x;
        for(int i=0;i<n;i++)
        {
            x.insert(a[i][0]);
        }
        if(x.size()!=n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        flag=0;
        for(int i=0;i<n-1;i++)
        {
            for(int j=0;j<m-1;j++)
            {
                if(a[i][j]==a[i][j+1] &&a[i][j]==a[i][0])
                    flag=1;
                else{
                    flag=0;
                break;}
            }
        }
        if(flag==0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
        return 0;

    }


#include <bits/stdc++.h>++
        typedef long long int ll;

    using namespace std;

    int main()
    {
        ios_base::sync_with_stdio(false);
          cin.tie(NULL);
        ll n,m,flag=0;
        cin>>n>>m;
        char a[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }
set<char,greater<char> > x;
        for(int i=0;i<n;i++)
        {
            x.insert(a[i][0]);
        }
        if(x.size()!=n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        flag=0;
        if(n==m && n==1)
            cout<<"YES"<<endl;
        else{
        for(int i=0;i<n;i++)
        {flag=0;
            for(int j=0;j<m-1;j++)
            {
                if(a[i][j]==a[i][j+1] &&a[i][j]==a[i][0])
                    flag=1;
                else{
                    flag=0;
                break;}
            }
        }
        if(flag==0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;}
        return 0;

    }


#include <bits/stdc++.h>++
        typedef long long int ll;

    using namespace std;

    int main()
    {
        ios_base::sync_with_stdio(false);
          cin.tie(NULL);
        ll n,m,flag=0;
        cin>>n>>m;
        char a[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }
set<int,greater<int> > x;
        for(int i=0;i<n;i++)
        {
            x.insert(a[i][0]);
        }
        if(x.size()!=n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        flag=0;
        for(int i=0;i<n-1;i++)
        {
            for(int j=0;j<m-1;j++)
            {
                if(a[i][j]==a[i][j+1])
                    flag=1;
                else{
                    flag=0;
                break;}
            }
        }
        if(flag==0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
        return 0;

    }


#include <bits/stdc++.h>++
        typedef long long int ll;

    using namespace std;

    int main()
    {
        ios_base::sync_with_stdio(false);
          cin.tie(NULL);
        ll n,m,flag=0;
        cin>>n>>m;
        char a[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }

        for(int i=0;i<n-1;i++)
        {
           if(a[i][0]==a[i+1][0])
           {
               flag=1;
               break;
           }
        }
        if(flag==1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        flag=0;
        if(n==m && n==1)
            cout<<"YES"<<endl;
        else{
        for(int i=0;i<n;i++)
        {flag=0;
            for(int j=0;j<m-1;j++)
            {
                if(a[i][j]==a[i][j+1] &&a[i][j]==a[i][0])
                    flag=1;
                else{
                    flag=0;
                break;}
            }
            if(flag==0)
                break;
        }
        if(flag==0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;}
        return 0;

    }


#include <bits/stdc++.h>++
        typedef long long int ll;

    using namespace std;

    int main()
    {
        ios_base::sync_with_stdio(false);
          cin.tie(NULL);
        ll n,m,flag=0;
        cin>>n>>m;
        char a[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }
set<char,greater<char> > x;
        for(int i=0;i<n;i++)
        {
            x.insert(a[i][0]);
        }
        if(x.size()!=n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        flag=0;
        for(int i=0;i<n;i++)
        {flag=0;
            for(int j=0;j<m-1;j++)
            {
                if(a[i][j]==a[i][j+1] &&a[i][j]==a[i][0])
                    flag=1;
                else{
                    flag=0;
                break;}
            }
        }
        if(flag==0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
        return 0;

    }


#include <bits/stdc++.h>++
        typedef long long int ll;

    using namespace std;

    int main()
    {
        ios_base::sync_with_stdio(false);
          cin.tie(NULL);
        ll n,m,flag=0;
        cin>>n>>m;
        char a[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }
set<char,greater<char> > x;
        for(int i=0;i<n;i++)
        {
            x.insert(a[i][0]);
        }cout<<x.size()
        if(x.size()!=n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        flag=0;
        for(int i=0;i<n;i++)
        {flag=0;
            for(int j=0;j<m-1;j++)
            {
                if(a[i][j]==a[i][j+1] &&a[i][j]==a[i][0])
                    flag=1;
                else{
                    flag=0;
                break;}
            }
        }
        if(flag==0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
        return 0;

    }


#include <bits/stdc++.h>++
        typedef long long int ll;

    using namespace std;

    int main()
    {
        ios_base::sync_with_stdio(false);
          cin.tie(NULL);
        ll n,m,flag=0;
        cin>>n>>m;
        char a[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }

        for(int i=0;i<n-1;i++)
        {
           if(a[i][0]==a[i+1][0])
           {
               flag=1;
               break;
           }
        }
        if(flag==1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        flag=0;
        if(m==1)
        {
             for(int i=0;i<n-1;i++)
        {
           if(a[i][0]==a[i+1][0])
           {
               flag=1;
               break;
           }
        }
        if(flag==1)
        {
            cout<<"NO"<<endl;

        }else
        cout<<"YES"<<endl;
        }

        else{
        for(int i=0;i<n;i++)
        {flag=0;
            for(int j=0;j<m-1;j++)
            {
                if(a[i][j]==a[i][j+1])
                    flag=1;
                else{
                    flag=0;
                break;}
            }
            if(flag==0)
                break;
        }
        if(flag==0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;}
        return 0;

    }


#include <bits/stdc++.h>++
        typedef long long int ll;

    using namespace std;

    int main()
    {
        ios_base::sync_with_stdio(false);
          cin.tie(NULL);
        ll n,m,flag=0;
        cin>>n>>m;
        char a[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }
set<char,greater<char> > x;
        for(int i=0;i<n;i++)
        {
            x.insert(a[i][0]);
        }
        if(x.size()!=n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        flag=0;
        for(int i=0;i<n-1;i++)
        {flag=0;
            for(int j=0;j<m-1;j++)
            {
                if(a[i][j]==a[i][j+1] &&a[i][j]==a[i][0])
                    flag=1;
                else{
                    flag=0;
                break;}
            }
        }
        if(flag==0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
        return 0;

    }


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n, m;
    bool b = true;
    cin >> n >> m;

    int** mas = new int* [n];
    string str[100];
    for (int i = 0; i < n; i++) {
        mas[i] = new int[m];
        cin >> str[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            mas[i][j] = int(str[i][j]);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 1; j < m; j++) {
            if (mas[i][0] != mas[i][j]) {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (i < (n - 1) && i>0) {
            if (mas[i - 1][0] == mas[i][0] || mas[i][0] == mas[i + 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }

        if (i == 0 && n>1) {
            if (mas[i][0] == mas[i + 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (i == (n-1)) {
            if (mas[i][0] == mas[i - 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    cout << "YES"<<endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n, m;
    bool b = true;
    cin >> n >> m;

    int** mas = new int* [n];
    string str[100];
    for (int i = 0; i < n; i++) {
        mas[i] = new int[m];
        cin >> str[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            mas[i][j] = int(str[i][j]);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 1; j < m; j++) {
            if (mas[i][0] != mas[i][j]) {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (i < (n - 1) && i>0) {
            if (mas[i - 1][0] == mas[i][0] || mas[i][0] == mas[i + 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }

        if (i == 0 && n>1) {
            if (mas[i][0] == mas[i + 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (i == (n-1) && n>1) {
            if (mas[i][0] == mas[i - 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    cout << "YES"<<endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, m;
    bool b = true;
    cin >> n >> m;

    int** mas = new int* [n];
    for (int i = 0; i < n; i++) {
        mas[i] = new int[m];
        for (int j = 0; j < m; j++) {
            cin >> mas[i][j];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 1; j < m; j++) {
            if (mas[i][0] != mas[i][j]) {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (i < (n - 1) && i>0) {
            if (mas[i - 1][0] == mas[i][0] || mas[i][0] == mas[i + 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }

        if (i == 0) {
            if (mas[i][0] == mas[i + 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (i == (n-1)) {
            if (mas[i][0] == mas[i - 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    cout << "YES"<<endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n, m;
    bool b = true;
    cin >> n >> m;

    int** mas = new int* [n];
    string str[100];
    for (int i = 0; i < n; i++) {
        mas[i] = new int[m];
        cin >> str[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            mas[i][j] = int(str[i][j]);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 1; j < m; j++) {
            if (mas[i][0] != mas[i][j]) {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (i < (n - 1) && i>0) {
            if (mas[i - 1][0] == mas[i][0] || mas[i][0] == mas[i + 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }

        if (i == 0) {
            if (mas[i][0] == mas[i + 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (i == (n-1)) {
            if (mas[i][0] == mas[i - 1][0]) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    cout << "YES"<<endl;
    return 0;
}


#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/

int n, m;
int f[102][102];

int main(){
    IOS;
    cin >> n >> m;
    F0R(i,n){
        F0R(j,m){
            cin >> f[j][i];
        }
    }
    int prevColor;
    int currColor;
    F0R(i,n){
        currColor = f[0][i];
        if(i > 0){
            if(currColor == prevColor){
                cout << "NO";
                return 0;
            }
        }
        F0R(j,m){
            if(f[j][i] != currColor){
                cout << "NO";
                return 0;
            }
        }
        prevColor = currColor;
    }
    cout << "YES";
    return 0;
}