#include <cstdio>
#include <cstring>
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define LL long long
const int maxn = 101000;
struct seg{
    LL sum[maxn << 2], add[maxn << 2];
    void PushUp(int rt){
        sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
    }
    void PushDown(int rt, int m){
        if (add[rt]){
            add[rt << 1] += add[rt];
            add[rt << 1 | 1] += add[rt];
            sum[rt << 1] += add[rt] * (m - (m >> 1));
            sum[rt << 1 | 1] += add[rt] * (m >> 1);
            add[rt] = 0;
        }
    }
    void build(int l, int r, int rt){
        add[rt] = 0;
        if (l == r){
            scanf("%I64d", &sum[rt]);
            return;
        }
        int m = (l + r) >> 1;
        build(lson);
        build(rson);
        PushUp(rt);
    }
    void update(int ll, int rr, LL c, int l, int r, int rt){
        if (ll <= l && rr >= r){
            sum[rt] += c * (r - l + 1);
            add[rt] += c;
            return;
        }
        PushDown(rt, r - l + 1);
        int m = (l + r) >> 1;
        if (ll <= m) update(ll, rr, c, lson);
        if (rr > m) update(ll, rr, c, rson);
        PushUp(rt);
    }
    LL query(int x, int l, int r, int rt){
        if (l == r) return sum[rt];
        PushDown(rt, r - l + 1);
        int m = (l + r) >> 1;
        if (x <= m) return query(x, lson);
        else return  query(x, rson);
    }
};
struct chg{
    int l, r;
    LL d;
    void get(){
        scanf("%d%d%I64d", &l, &r, &d);
    }
}x[maxn];
seg a, b;
int main(){
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)){
        a.build(1, n, 1);
        memset(b.sum, 0, sizeof(b.sum));
        memset(b.add, 0, sizeof(b.add));
        for (int i = 1; i <= m; i++) x[i].get();
        for (int i = 1; i <= k; i++){
            int l, r;
            scanf("%d%d", &l, &r);
            b.update(l, r, 1, 1, m, 1);
        }
        for (int i = 1; i <= m; i++){
            LL tt = b.query(i, 1, m, 1);
            a.update(x[i].l, x[i].r, x[i].d * tt, 1, n, 1);
        }
        for (int i = 1; i <= n; i++){
            LL ans = a.query(i, 1, n, 1);
            printf("%I64d ", ans);
        }
        printf("\n");
    }
    return 0;
}


// C++ program to illustrate
// sin trigonometric function

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

int main()
{
   long long  t,n,count,need,live,M,temp;
   bool done;
   cin>>t;
   while(t--){
       done=0;
     count=1;
     cin>>n;
     vector<long long> a(n);
     for(int i=0;i<n;i++) cin>>a[i];
     sort(a.begin(),a.end());
     for(int i=0;i<n;i++){
         if(a[i]<=count){
             //cout<<a[i]<<endl;
             count++;
         }
         else{
             need = a[i]-count;
            //  temp = need+i;
            //  live = a[i];
             M=need;
             while(M>=1 && i<n){
                 //cout<<i<<' '<<a[i]<<' '<<M<<endl;
                 temp = M+i;
                 live = a[i];
                 i++;
                 //cout<<"l: "<<live<<' '<<temp<<endl;
                 M=INT_MIN;
                 //cout<<"t: "<<temp<<endl;
                 while(i<n && i<=temp){

                     need = a[i]-live;
                    //  if(need>M){
                    //      M =need;
                    //      live = a[i];
                    //  }
                    M = max(M,need);
                     //cout<<"h: "<<a[i]<<' '<<M<<' '<<temp<<endl;
                     i++;
                 }
                 //cout<<"M: "<<M<<endl;
                 i--;
                 if(i==temp && i<n && M<=0){
                     //cout<<"a: "<<a[i]<<endl;
                     done=1;
                     count=a[i]+1;
                 }
             }
         }
     }
     //if(done==1) count++;
     cout<<count<<endl;
   }
	return 0;
}


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

 int main()
 {
	long long n;
	cin >> n;
	while(n--){
		int a;
		cin >> a;
		int x[a + 100];
		for ( int i = 0; i < a; ++i )cin >> x[i];
		sort(x, x + a);
		int c;
		for ( int i = 0; i < a; ++i ){
			if (i + 1 >= x[i])c=i + 1;
		}
		cout << c + 1 << "\n";
	}
}


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

 int main()
 {
	long long n;
	cin >> n;
	while(n--){
		int a;
		cin >> a;
		int x[a + 100];
		for ( int i = 0; i < a; ++i )cin >> x[i];
		sort(x, x + a);
		int c;
		for ( int i = 0; i < a; ++i ){
			if (i + 1 <= x[i])c=i + 1;
		}
		cout << c + 1 << "\n";
	}
}


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

 int main()
 {
	long long n;
	cin >> n;
	while(n--){
		int a;
		cin >> a;
		int x[a + 100];
		for ( int i = 0; i < a; ++i )cin >> x[i];
		sort(x, x + a);
		int ans=0;
		int c=1;
		for ( int i = 0; i < a; ++i ){
	       if (c >= x[i])ans = c + 1;
	       c++;
	    }
	    cout << ans << "\n";
	}
}


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

 int main()
 {
	long long n;
	cin >> n;
	while(n--){
		int a;
		cin >> a;
		int x[a + 100];
		for ( int i = 0; i < a; ++i )cin >> x[i];
		sort(x, x + a);
		int ans=1;
		int c=1;
		for ( int i = 0; i < a; ++i ){
	       if (c >= x[i])ans = c + 1;
	       c++;
	    }
	    cout << ans << "\n";
	}
}


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

 int main()
 {
	long long n;
	cin >> n;
	while(n--){
		int a;
		cin >> a;
		int x[a + 100];
		for ( int i = 0; i < a; ++i )cin >> x[i];
		sort(x, x + a);
		int ans;
		for ( int i = 0; i < a; ++i ){
	       if (x[i] >= i + 1)ans = i + 2;
	    }
	    cout << ans << "\n";
	}
}


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

 int main()
 {
	long long n;
	cin >> n;
	while(n--){
		int a;
		cin >> a;
		int x[a + 100];
		for ( int i = 0; i < a; ++i )cin >> x[i];
		sort(x, x + a);
		int ans=0;
		for ( int i = 0; i < a; ++i ){
	       if (x[i] <= i + 1)ans = i + 1;
	    }
	    if (ans = 0)cout<< "1\n";
	    else cout << ans + 1 << "\n";
	}
}


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

 int main()
 {
	long long n;
	cin >> n;
	while(n--){
		int a;
		cin >> a;
		int x[a + 100];
		for ( int i = 0; i < a; ++i )cin >> x[i];
		sort(x, x + a);
		int ans;
		for ( int i = 0; i < a; ++i ){
	       if (x[i] <= i + 1)ans = i + 2;
	    }
	    cout << ans << "\n";
	}
}


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

int main()
{
	int a[10001] = {};
	int t,n;
	scanf("%d", &t);
	while(t--)
	{
		scanf("%d", &n);
		for (int i=1; i<=n; i++)
			scanf("%d", &a[i]);
		sort(a+1, a+1+n);
		int max_num = 1;
		for (int i=n; i>0; i--)
			if (a[i]<=i)
			{
				max_num = i+1;
				break;
			}
		printf("%d\n", max_num);
	}
	return 0;
}


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

int main()
{
	int a[100001] = {};
	int t,n;
	scanf("%d", &t);
	while(t--)
	{
		scanf("%d", &n);
		for (int i=1; i<=n; i++)
			scanf("%d", &a[i]);
		sort(a+1, a+1+n);
		int max_num = 1;
		for (int i=n; i>0; i--)
			if (a[i]<=i)
			{
				max_num = i+1;
				break;
			}
		printf("%d\n", max_num);
	}
	return 0;
}


#include<bits/stdc++.h>
 using namespace std;
 #define int long long
 #define endl "\n"
 const int mod=1e9+7;
 #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define clr(a,x) memset(a,x,sizeof(a))
 #define T int t;cin>>t; while(t--)
 #define vll vector<int>
 #define v22 vactor<vector<int>>
#define pb push_back
 #define sz size
 #define str to_string
 #define intt stoll
 #define sv() sort(a.begin(),a.end())
 #define vp vector<pair<int, int>> b(n)
 bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
  int32_t main()
  {
   T{
  int n,c=0,x=0,y=0;
  cin>>n;
  int a[200001]={0};
  for(int i=0;i<n;i++)
  {
  cin>>x;
  a[x]++;
   y=max(y,x);
  }
  for(int i=1;i<=y;i++)
    a[i]=a[i]+a[i-1];
    for(int i=0;i<=y;i++)
    {
      if(a[i]>=i)
      c=a[i];
    }
    cout<<c+1<<endl;
  }
  }


#include<bits/stdc++.h>
 using namespace std;
 #define int long long
 #define endl "\n"
 const int mod=1e9+7;
 #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define clr(a,x) memset(a,x,sizeof(a))
 #define T int t;cin>>t; while(t--)
 #define vll vector<int>
 #define v22 vactor<vector<int>>
#define pb push_back
 #define sz size
 #define str to_string
 #define intt stoll
 #define sv() sort(a.begin(),a.end())
 #define vp vector<pair<int, int>> b(n)
 bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
  int32_t main()
  {
   T{
  int n,c=0,x=0,y=0;
  cin>>n;
  int a[1000000]={0};
  for(int i=0;i<n;i++)
  {
  cin>>x;
  a[x]++;
   y=max(y,x);
  }
  for(int i=1;i<=y;i++)
    a[i]=a[i]+a[i-1];
    for(int i=0;i<=y;i++)
    {
      if(a[i]>=i)
      c=a[i];
    }
    cout<<c+1<<endl;
  }
  }


#include<bits/stdc++.h>
 using namespace std;
 #define int long long
 #define endl "\n"
 const int mod=1e9+7;
 #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define clr(a,x) memset(a,x,sizeof(a))
 #define T int t;cin>>t; while(t--)
 #define vll vector<int>
 #define v22 vactor<vector<int>>
#define pb push_back
 #define sz size
 #define str to_string
 #define intt stoll
 #define sv() sort(a.begin(),a.end())
 #define vp vector<pair<int, int>> b(n)
 bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
  int32_t main()
  {
   T{
  int n,c=0,x=0,y=-1;
  cin>>n;
  vll a(n);
  for(int i=0;i<n;i++)
  cin>>a[i];
  sv();
    for(int i=0;i<a.size();i++)
    {
      c++;
      if(c>=a[i])
        y=i;
    }
    cout<<y+2<<endl;
  }
  }


#include<bits/stdc++.h>
 using namespace std;
 #define int long long
 #define endl "\n"
 const int mod=1e9+7;
 #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define clr(a,x) memset(a,x,sizeof(a))
 #define T int t;cin>>t; while(t--)
 #define vll vector<int>
 #define v22 vactor<vector<int>>
#define pb push_back
 #define sz size
 #define str to_string
 #define intt stoll
 #define sv() sort(a.begin(),a.end())
 #define vp vector<pair<int, int>> b(n)
 bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
  int32_t main()
  {
   T{
  int n,c=0,x=0,y=0;
  cin>>n;
  int a[200000]={0};
  for(int i=0;i<n;i++)
  {
  cin>>x;
  a[x]++;
   y=max(y,x);
  }
  for(int i=1;i<=y;i++)
    a[i]=a[i]+a[i-1];
    for(int i=0;i<=y;i++)
    {
      if(a[i]>=i)
      c=a[i];
    }
    cout<<c+1<<endl;
  }
  }


#include<bits/stdc++.h>
 using namespace std;
 #define int long long
 #define endl "\n"
 const int mod=1e9+7;
 #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define clr(a,x) memset(a,x,sizeof(a))
 #define T int t;cin>>t; while(t--)
 #define vll vector<int>
 #define v22 vactor<vector<int>>
#define pb push_back
 #define sz size
 #define str to_string
 #define intt stoll
 #define sv() sort(a.begin(),a.end())
 #define vp vector<pair<int, int>> b(n)
 bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
  int32_t main()
  {
   T{
  int n,c=0,x=0,y=0;
  cin>>n;
  int a[200000]={0};
  for(int i=0;i<n;i++)
  {
  cin>>x;
  a[x]++;
   y=max(y,x);
  }
  if(a[1]==0)
  cout<<1<<endl;
  else
  {
  for(int i=1;i<=y;i++)
    a[i]=a[i]+a[i-1];
    for(int i=0;i<=y;i++)
    {
      if(a[i]>=i)
      c=a[i];
    }
    cout<<c+1<<endl;
  }
  }
  }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
typedef unsigned long long ull;
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define endl "\n"
#define pb push_backtio;
int main()
{
    fastio;
    ll t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int arr[n];
        for (int i = 0; i < n; i++)
            cin >> arr[i];
        sort(arr, arr + n);
        int sum_till_now = 1;
        int confirmed_sum = 1;
        // for (int i = 0; i < n; i++)
        //     cout << arr[i] << " ";
        // cout << " ";
        if (arr[0] >= 2)
        {
            cout << 1 << endl;
            continue;
        }
        for (int i = 0; i < n; i++)
        {
            if (arr[i] <= sum_till_now)
            {
                sum_till_now++;
                // cout << arr[i] << "&" << i;
                confirmed_sum = sum_till_now;
            }
            else
            {
                sum_till_now++;
            }
        }
        // cout << "----";
        cout << confirmed_sum << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
typedef unsigned long long ull;
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define endl "\n"
#define pb push_backtio;
int main()
{
    fastio;
    ll t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int arr[n];
        for (int i = 0; i < n; i++)
            cin >> arr[i];
        sort(arr, arr + n);
        // for (int i = 0; i < n; i++)
        //     cout << arr[i] << " ";
        // cout << " ";

        int people_in_queue = 0;
        int ans = 1;
        for (int i = 0; i < n; i++)
        {
            if (arr[i] <= ans + people_in_queue)
            {
                ans = (i + 2);
                people_in_queue = 0;
            }
            else
            {
                people_in_queue++;
            }
        }
        cout << ans << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
typedef unsigned long long ull;
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define endl "\n"
#define pb push_backtio;
int main()
{
    fastio;
    ll t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int arr[n];
        for (int i = 0; i < n; i++)
            cin >> arr[i];
        sort(arr, arr + n);
        // for (int i = 0; i < n; i++)
        //     cout << arr[i] << " ";
        // cout << " ";
        if (arr[0] >= 2)
        {
            cout << 1 << endl;
            continue;
        }
        int people_in_queue = 0;
        int ans = 1;
        for (int i = 0; i < n; i++)
        {
            if (arr[i] <= ans + people_in_queue)
            {
                ans = (i + 2);
                people_in_queue = 0;
            }
            else
            {
                people_in_queue++;
            }
        }
        cout << ans << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
typedef unsigned long long ull;
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define endl "\n"
#define pb push_backtio;
int main()
{
    fastio;
    ll t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int arr[n];
        for (int i = 0; i < n; i++)
            cin >> arr[i];
        sort(arr, arr + n);
        // for (int i = 0; i < n; i++)
        //     cout << arr[i] << " ";
        // cout << " ";
        if (arr[0] >= 2)
        {
            cout << 1 << endl;
            continue;
        }
        int lastOne = -1;
        int ans = 1;
        for (int i = 0; i < n; i++)
        {
            if (arr[i] <= ans)
            {
                lastOne = i;
            }
            ans++;
        }
        cout << lastOne + 2 << endl;
    }
}


  #include <iostream>
  #include <algorithm>
  #include <stdlib.h>
  #include <time.h>
  using namespace std;

  void solve()
  {
    int n,a[1000],count=1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(int i=n;i>0;i--)
    {
      if(a[i]<=i)
      {
        count+=i;
        break;
      }
    }
    cout<<count<<endl;
  }

  int main()
  {
    int t;
    cin >> t;
    while (t--)
    {
      solve();
    }
    return 0;
  }


  #include <iostream>
  #include <algorithm>
  #include <stdlib.h>
  #include <time.h>
  using namespace std;

  void solve()
  {
    int n,a[100005],count=1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(int i=n;i>0;i--)
    {
      if(a[i]<=i)
      {
        count+=i;
        break;
      }
    }
    cout<<count<<endl;
  }

  int main()
  {
    int t;
    cin >> t;
    while (t--)
    {
      solve();
    }
    return 0;
  }


  #include <iostream>
  #include <algorithm>
  #include <stdlib.h>
  #include <time.h>
  using namespace std;

  void solve()
  {
    int n,a[10005],count=1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(int i=n;i>0;i--)
    {
      if(a[i]<=i)
      {
        count+=i;
        break;
      }
    }
    cout<<count<<endl;
  }

  int main()
  {
    int t;
    cin >> t;
    while (t--)
    {
      solve();
    }
    return 0;
  }


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll t,n,x;
    cin>>t;
    while(t--)
    {
        cin>>n;
        vector<ll>v,u;
        for(ll i=0;i<n;i++)
        {
            cin>>x;
            u.push_back(x);
        }
        sort(u.begin(),u.end());
        if(u[0]>1) cout<<1<<endl;
        else
        {
            ll g;
            for(ll i=u.size()-1;i>=0;i--)
            {
                if(u[i]<=i+1)
                {
                    g=i+2;
                    break;
                }
            }
            cout<<g<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll t,n,x;
    cin>>t;
    while(t--)
    {
        cin>>n;
        vector<ll>v,u;
        for(ll i=0; i<n; i++)
        {
            cin>>x;
            u.push_back(x);
        }
        sort(u.begin(),u.end());
        ll g=1,c=0,y=0;
        for(ll i=0; i<u.size(); i++)
        {
            if(u[i]<=g)
                g=i+2;
            else
            {
                c++;
                if(g+c-1 >= u[i])
                {
                    g=g+c;
                    c=0;
                }
            }
        }
        cout<<g<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll t,n,x;
    cin>>t;
    while(t--)
    {
        cin>>n;
        vector<ll>v,u;
        for(ll i=0;i<n;i++)
        {
            cin>>x;
            v.push_back(x);
            u.push_back(x);
        }
        sort(u.begin(),u.end());
        if(u[0]>1) cout<<1<<endl;
        else
        {
            ll g=1,c=0,y=0;
            for(ll i=0;i<u.size();i++)
            {
                if(u[i]<=g) g++;
                else if(u[i]-g==1)
                {
                    x=u[i];
                    y=0;
                    while(abs(x-u[i])<=1)
                    {
                        c++;
                        y=max(y,u[i]);
                        i++;
                    }
                    if(g+c-1 >= y) g+=c;
                }
                else break;
            }
            cout<<g<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll t,n,x;
    cin>>t;
    while(t--)
    {
        cin>>n;
        vector<ll>v,u;
        for(ll i=0;i<n;i++)
        {
            cin>>x;
            v.push_back(x);
            if(x<=n) u.push_back(x);
        }
        sort(u.begin(),u.end());
        if(u[0]>1) cout<<1<<endl;
        else
        {
            ll g=1,c=0,y=0;
            for(ll i=u.size()-1;i>=0;i--)
            {
                if(u[i]<=i+1)
                {
                    g=i+2;
                    break;
                }
            }
            cout<<g<<endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define lli long long int
using namespace std;
int t,n,x,ans,mx;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>t;
    while(t--){
        cin>>n;
        mx=0;
        ans=1;
        int f[200009]={};
        while(n--){
            cin>>x;
            f[x]++;
            mx=max(mx,x);
        }
        for(int i=1;i<=mx;i++){
            f[i]+=f[i-1];
        }
        for(int i=mx;i>=0;i--){
            if(i<=f[i]){
                ans+=f[i];
                break;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define lli long long int
using namespace std;
lli t,n,cur,ans,mx,arr[200009],num[200009];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>t;
    while(t--){
        cin>>n;
        ans=1;
        int con=0;
        num[0]=1;
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        sort(arr,arr+n);
        for(int i=0;i<n;i++){
            if(arr[i]<=ans+con)ans+=con+1;
            else{
                con++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int t,n,ans,arr[200009];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>t;
    while(t--){
        cin>>n;
        ans=1;
        int con=0;
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        sort(arr,arr+n);
        for(int i=0;i<n;i++){
            if(arr[i]<=ans+con){
                ans+=con+1;
                if(con){
                    con=0;
                }
            }
            else{
                con++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int T , n , arr[100005] , mn;
int main(){
	cin >> T;
	while(T--){
		cin >> n;
		int t[200005] = {0};
		mn = 0;
		for(int i = 1; i <= n; i++){
			cin >> arr[i];
			t[arr[i]]++;
			mn = max(mn , arr[i]);
		}
		int na = 1 , s = 0;
		for(int i = 1; i <= mn; i++){
			bool o = false;
			for(int j = t[i]; j >= 0; j--){
				if(na + j + s > i){
					na += j + s;
					s = 0;
					o = true;
					break;
				}
			}
			if(o == false){
				s += t[i];
			}
		}
		cout << na << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    scanf("%d",&n);
    while(n--){
        int t;
        scanf("%d",&t);
        int a[t+1];
        for (int i=1;i<=t;i++){
            scanf("%d",&a[i]);
        }
        sort(a+1,a+t+1);
        int j;
        for (j=t;j>=1;j--){
            if(j>=a[j]){
                break;
            }
        }
        printf("%d\n",j+1);
    }
    return 0;
}


#pragma GCC optimize(3)
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

const int N=100005;

int n,people,a[N];

int main() {
    scanf("%d",&people);
	for(int t=1;t<=people;++t) {
        scanf("%d",&n);
		for(int i=1;i<=n;++i) scanf("%d",&a[i]);
		sort(a+1,a+1+n);
		int ans=0;
		for(int i=1;i<=n;++i)
			if(i>=a[i])
				ans=i;
		printf("%d\n",ans+1); //+1: Add yourself.
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf=0x3f3f3f3f;
const int N=1e5+10;
int a[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        sort(a+1,a+n+1);
        int ans=1;
        for(int i=1;i<=n;i++)
        {
            if(i>=a[i]) ans=max(ans,i+1);
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=200010;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int a[N];
signed main()
{
	for(ri int T=read();T;T--)
	{
		int n=read();
		for(ri int i=1;i<=n;i++) a[i]=read();
		sort(a+1,a+1+n); int res=0;
		for(ri int i=1;i<=n;i++) if(a[i]<=i) res=i;
		printf("%lld\n",res+1);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef unsigned long ll;
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(a) a.begin(),a.end()
const ll DIG_L = numeric_limits<ll>::digits;
const int maxi=100000;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, b = 0,i;
        cin >> n;
        int s[n];
        for (i = 0; i < n; i++)
            cin >> s[i];
            sort(s,s+n);
        for (i = n - 1; i >=0; i--)
        {
            if (i + 1 >= s[i])
            {
                b = i + 1;
                break;
            }
            else
                continue;
        }
        cout << b + 1 << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, b = 0,i;
        cin >> n;
        int s[n];
        for (i = 0; i < n; i++)
            cin >> s[i];
        for (i = n - 1; i >=0; i--)
        {
            if (i + 1 >= s[i])
            {
                b = i + 1;
                break;
            }
            else
                continue;
        }
        cout << b + 1 << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, b = 0,i;
        cin >> n;
        int s[n];
        for (i = 0; i < n; i++)
            cin >> s[i];
        for (i = n - 1; i > 0; i--)
        {
            if (i + 1 >= s[i])
            {
                b = i + 1;
                break;
            }
            else
                continue;
        }
        cout << b + 1 << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	long long n,i,b,m,x,j,r,s,p;

	cin>>n>>m;
	long long a[100005];
	p=1;
	for(i=1; i<=n; i++) {
		scanf("%lld", & x);
		for(j=1; j<=x; j++) {
			a[p]=j;
			p++;
		}
	}
	r=0;
	for(i=1; i<=p; i++) {
		s=0;
		if(i+m-1<=p) {
			for(j=i; j<i+m; j++) {
				s=s+a[j];
			}
		}
		else {
			for(j=i; j<=p; j++) {
				s=s+a[j];
			}
			for(j=1; j<=(i+m-p); j++) {
				s=s+a[j];
			}
		}
		r=max(r,s);
	}
	cout<<r<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	long long n,i,b,m,x,j,r,s,p;

	cin>>n>>m;

	for(i=1; i<=n; i++) {
		cin>>m;
		long long a[m+1];
		p=1;
		for(j=1; j<=m; j++) {
			cin>>a[j];
			if(a[j]<=p)  p++;
		}
		cout<<p<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	long long i,t,n,j,r,p,p1,m,r1;

	cin>>t;

	for(i=1; i<=t; i++) {
		cin>>n;
		long long a[n+1];
		p=1;
		for(j=1; j<=n; j++) {
			cin>>a[j];
		}
		sort(a+1,a+n+1);
		p1=1;
		while(p1!=0) {
			if(n==1) {
				p1=0;
			}
			if(a[n]<=n) {
				p1=0;
			}
			else n--;
		}
		cout<<n+1<<endl;
	}
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	long long n,i,b,m,x,j,r,s,p;

	cin>>n;

	for(i=1; i<=n; i++) {
		cin>>m;
		long long a[m+1];
		p=1;
		for(j=1; j<=m; j++) {
			cin>>a[j];
			if(a[j]<=p)  p++;
		}
		cout<<p<<endl;
	}
	return 0;
}


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

using namespace std;

long long n, test, m, k=0   , tk, sum=0, mn_=INT_MAX, cnt=0, a, b, c, d;

vector<long long >v;

int main()
{

    cin>>test;
    while(test--){
        cin>>a;

        v.clear();
        for(int i=0; i<a; i++){
                cin>>n;
                v.push_back(n);
        }

        sort(v.begin(), v.end());

//        for(int i=0; i<a; i++)cout<<v[i];
//        cout<<endl;
        if( v[a-1] <= a){
            cout<<a+1<<endl;
            continue;
        }
        if( v[0] > 1){
            cout<<1<<endl;
        }

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

}


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

using namespace std;

long long n, test, m, k=0   , tk, sum=0, mn_=INT_MAX, cnt=0, a, b, c, d;

vector<long long >v;

int main()
{

    cin>>test;
    while(test--){
        cin>>a;

        v.clear();
        for(int i=0; i<a; i++){
                cin>>n;
                v.push_back(n);
        }

        sort(v.begin(), v.end());

//        for(int i=0; i<a; i++)cout<<v[i];
//        cout<<endl;
        if( v[a-1] <= a){
            cout<<a+1<<endl;
            continue;
        }
        bool paici = false;
        for(int i=a-1; i>=0; i--){
            if( v[i] <= i+1){
                cout<< i+2<<endl;
                paici = true;
                break;
            }
        }
        if (!paici)cout<<1<<endl;
    }

}


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

using namespace std;

long long n, test, m, k=0   , tk, sum=0, mn_=INT_MAX, cnt=0, a, b, c, d;

vector<long long >v;

int main()
{

    cin>>test;
    while(test--){
        cin>>a;

        v.clear();
        for(int i=0; i<a; i++){
                cin>>n;
                v.push_back(n);
        }

        sort(v.begin(), v.end());

//        for(int i=0; i<a; i++)cout<<v[i];
//        cout<<endl;
        if( v[a-1] <= a){
            cout<<a+1<<endl;
            continue;
        }
        if( v[0] > 1){
            cout<<1<<endl;
        }

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

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    int n,ans;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++)
          cin>>arr[i];
        sort(arr,arr+n);
        if(arr[n-1]<=n)
        {
            cout<<n+1<<"\n";
            continue;
        }
        int c=1;
        for(int i=n-2;i>=0;i--)
        {
            if(arr[i]<=(n-1))
            {
                ans=i+2;
                break;
            }
            else
                c++;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    int n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++)
          cin>>arr[i];
        sort(arr,arr+n);
        int count=1;
        int ans=1;
        for(int i=0;i<n;i++)
        {
            if(arr[i]<=count)
              ans=count+1;
            count++;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    int n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++)
          cin>>arr[i];
        sort(arr,arr+n);
        int count=1;
        for(int i=0;i<n;i++)
        {
            if(arr[i]<=count)
              count=i+2;
        }
        cout<<count<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    int n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++)
          cin>>arr[i];
        sort(arr,arr+n);
        int sum=1,count=1;
        for(int i=0;i<n;i++)
        {
            if(arr[i]<=sum)
              count++;
            sum++;
        }
        cout<<count<<"\n";
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn = 200000 + 5;
int n, a[maxn], s[maxn];
int main()
{
	int t;
	scanf("%d", &t);
	while(t --)
	{
		memset(a, 0, sizeof(a));
		memset(s, 0, sizeof(s));
		scanf("%d", &n);
		int val = 0;
		for(int i = 0; i < n; ++ i)
		{
			scanf("%d", &a[i]);
			val = max(val, a[i]);
			s[a[i]] ++;
		}
		sort(a, a + n);
		int m = unique(a, a + n) - a;
		s[0] = 1;
		for(int i = 0; i < m; ++ i)
		{
			if(i >= 1) s[a[i]] += s[a[i - 1]];
			else s[a[i]] ++;
		}
		bool valid = false;
		for(int i = m - 1; i >= 0; -- i)
		{
			if(s[a[i]] >= a[i] + 1)
			{
				printf("%d\n", s[a[i]]);
				valid = true;
				break;
			}
		}
		if(valid == false)
		{
			puts("1");
		}
	}
	return 0;
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn = 10000 + 5;
int n, a[maxn], s[maxn];
int main()
{
	int t;
	scanf("%d", &t);
	while(t --)
	{
		memset(s, 0, sizeof(s));
		scanf("%d", &n);
		int val = 0;
		for(int i = 0; i < n; ++ i)
		{
			scanf("%d", &a[i]);
			val = max(val, a[i]);
			s[a[i]] ++;
		}
		sort(a, a + n);
		int m = unique(a, a + n) - a;
		s[0] = 1;
		for(int i = 0; i < m; ++ i)
		{
			s[a[i]] += s[a[i - 1]];
		}
		bool valid = false;
		for(int i = m - 1; i >= 0; -- i)
		{
			if(s[a[i]] >= a[i] + 1)
			{
				printf("%d\n", s[a[i]]);
				valid = true;
				break;
			}
		}
		if(valid == false)
		{
			puts("1");
		}
	}
	return 0;
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn = 10000 + 5;
int n, a[maxn], s[maxn];
int main()
{
	int t;
	scanf("%d", &t);
	while(t --)
	{
		memset(a, 0, sizeof(a));
		memset(s, 0, sizeof(s));
		scanf("%d", &n);
		int val = 0;
		for(int i = 0; i < n; ++ i)
		{
			scanf("%d", &a[i]);
			val = max(val, a[i]);
			s[a[i]] ++;
		}
		sort(a, a + n);
		int m = unique(a, a + n) - a;
		s[0] = 1;
		for(int i = 0; i < m; ++ i)
		{
			s[a[i]] += s[a[i - 1]];
		}
		bool valid = false;
		for(int i = m - 1; i >= 0; -- i)
		{
			if(s[a[i]] >= a[i] + 1)
			{
				printf("%d\n", s[a[i]]);
				valid = true;
				break;
			}
		}
		if(valid == false)
		{
			puts("1");
		}
	}
	return 0;
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn = 10000 + 5;
int n, a[maxn], s[maxn];
int main()
{
	int t;
	scanf("%d", &t);
	while(t --)
	{
		memset(a, 0, sizeof(a));
		memset(s, 0, sizeof(s));
		scanf("%d", &n);
		int val = 0;
		for(int i = 0; i < n; ++ i)
		{
			scanf("%d", &a[i]);
			val = max(val, a[i]);
			s[a[i]] ++;
		}
		sort(a, a + n);
		int m = unique(a, a + n) - a;
		s[0] = 1;
		for(int i = 0; i < m; ++ i)
		{
			if(i >= 1) s[a[i]] += s[a[i - 1]];
			else s[a[i]] ++;
		}
		bool valid = false;
		for(int i = m - 1; i >= 0; -- i)
		{
			if(s[a[i]] >= a[i] + 1)
			{
				printf("%d\n", s[a[i]]);
				valid = true;
				break;
			}
		}
		if(valid == false)
		{
			puts("1");
		}
	}
	return 0;
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn = 20000 + 5;
int n, a[maxn], s[maxn];
int main()
{
	int t;
	scanf("%d", &t);
	while(t --)
	{
		memset(a, 0, sizeof(a));
		memset(s, 0, sizeof(s));
		scanf("%d", &n);
		int val = 0;
		for(int i = 0; i < n; ++ i)
		{
			scanf("%d", &a[i]);
			val = max(val, a[i]);
			s[a[i]] ++;
		}
		sort(a, a + n);
		int m = unique(a, a + n) - a;
		s[0] = 1;
		for(int i = 0; i < m; ++ i)
		{
			if(i >= 1) s[a[i]] += s[a[i - 1]];
			else s[a[i]] ++;
		}
		bool valid = false;
		for(int i = m - 1; i >= 0; -- i)
		{
			if(s[a[i]] >= a[i] + 1)
			{
				printf("%d\n", s[a[i]]);
				valid = true;
				break;
			}
		}
		if(valid == false)
		{
			puts("1");
		}
	}
	return 0;
}


#include<vector>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define FOR1(i,a,b) for(ll i=(a);i<(b);i++)
#define FOR2(i,a,b) for(ll i=(a);i<=(b);i++)
#define DEC1(i,a,b) for(int i=(a);i>(b);i--)
#define DEC2(i,a,b) for(int i=(a);i>=(b);i--)
//#define mp make_pair
#define pb push_back
#define ll long long
#define kl k<<1
#define kr k<<1|1
const int maxn = 1e5 + 10;
int a[maxn];
int main() {
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		FOR2(i, 1, n) {
			cin >> a[i];
		}
		ll ans = 1;
		ll ans2 = 1;
		int flag = 0;
		sort(a, a + n + 1);
		FOR2(i, 1, n) {
			if (a[i] <= ans2) {
				ans2++;
				ans = ans2;
			}
			else {
				flag = 1;
				ans2++;
			}
		}
		cout << ans << endl;
		memset(a, 0, sizeof(a));
	}
	return 0;
}


#include<vector>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define FOR1(i,a,b) for(ll i=(a);i<(b);i++)
#define FOR2(i,a,b) for(ll i=(a);i<=(b);i++)
#define DEC1(i,a,b) for(int i=(a);i>(b);i--)
#define DEC2(i,a,b) for(int i=(a);i>=(b);i--)
//#define mp make_pair
#define pb push_back
#define ll long long
#define kl k<<1
#define kr k<<1|1
const int maxn = 1e5 + 10;
int a[maxn];
int main() {
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		FOR2(i, 1, n) {
			int temp; cin >> temp;
			a[temp]++;
		}
		ll ans = 1;
		FOR2(i, 1, n) {
			if (a[i] == 0)	continue;
			if (i <= ans + a[i] - 1) {
				ans += a[i];
			}
			else {
				int ans2 = ans; int flag = 0;
				int j = i + 1;
				for ( ; j <= n; j++) {
					if (a[j] == 0)	continue;
					if (j <= ans2 + a[j] + a[i] - 1) {
						ans2 += (a[j] + a[i]);
						flag = 1;
						break;
					}
					ans2 += a[j];
				}
				if (flag == 0)	break;
				else {
					ans = ans2;
					i = j;
				}
			}
		}
		cout << ans << endl;
		memset(a, 0, sizeof(a));
	}
	return 0;
}


#include<vector>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define FOR1(i,a,b) for(ll i=(a);i<(b);i++)
#define FOR2(i,a,b) for(ll i=(a);i<=(b);i++)
#define DEC1(i,a,b) for(int i=(a);i>(b);i--)
#define DEC2(i,a,b) for(int i=(a);i>=(b);i--)
//#define mp make_pair
#define pb push_back
#define ll long long
#define kl k<<1
#define kr k<<1|1
const int maxn = 1e5 + 10;
int a[maxn];
int main() {
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		FOR2(i, 1, n) {
			int temp; cin >> temp;
			a[temp]++;
		}
		ll ans = 1;
		FOR2(i, 1, n) {
			if (a[i] == 0)	continue;
			if (i <= ans + a[i] - 1) {
				ans += a[i];
			}
			else {
				int ans2 = ans;
				int j = i + 1;
				for ( ; j <= n; j++) {
					if (a[j] == 0)	continue;
					if (j <= ans2 + a[j] + a[i] - 1) {
						ans2 += (a[j] + a[i]);
						break;
					}
					ans2 += a[j];
				}
				if (ans2 == ans)	break;
				else {
					ans = ans2;
					i = j;
				}
			}
		}
		cout << ans << endl;
		memset(a, 0, sizeof(a));
	}
	return 0;
}


#include<vector>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define FOR1(i,a,b) for(ll i=(a);i<(b);i++)
#define FOR2(i,a,b) for(ll i=(a);i<=(b);i++)
#define DEC1(i,a,b) for(int i=(a);i>(b);i--)
#define DEC2(i,a,b) for(int i=(a);i>=(b);i--)
//#define mp make_pair
#define pb push_back
#define ll long long
#define kl k<<1
#define kr k<<1|1
const int maxn = 1e5 + 10;
int a[maxn];
int main() {
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		FOR2(i, 1, n) {
			int temp; cin >> temp;
			a[temp]++;
		}
		ll ans = 1;
		FOR2(i, 1, n) {
			if (a[i] == 0)	continue;
			if (i <= ans + a[i] - 1) {
				ans += a[i];
			}
			else {
				int ans2 = ans;
				int j = i + 1;
				for ( ; j <= n; j++) {
					if (a[j] == 0)	continue;
					if (j <= ans2 + a[j] + a[i] - 1) {
						ans2 += (a[j] + a[i]);
						break;
					}
				}
				if (ans2 == ans)	break;
				else {
					ans = ans2;
					i = j;
				}
			}
		}
		cout << ans << endl;
		memset(a, 0, sizeof(a));
	}
	return 0;
}


#include<vector>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define FOR1(i,a,b) for(ll i=(a);i<(b);i++)
#define FOR2(i,a,b) for(ll i=(a);i<=(b);i++)
#define DEC1(i,a,b) for(int i=(a);i>(b);i--)
#define DEC2(i,a,b) for(int i=(a);i>=(b);i--)
//#define mp make_pair
#define pb push_back
#define ll long long
#define kl k<<1
#define kr k<<1|1
const int maxn = 1e5 + 10;
int a[maxn];
int main() {
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		FOR2(i, 1, n) {
			int temp; cin >> temp;
			a[temp]++;
		}
		ll ans = 1;
		FOR2(i, 1, n) {
			if (a[i] == 0)	continue;
			if (i <= ans + a[i] - 1) {
				ans += a[i];
			}
			else {
				if (i == n)	break;
				int ans2 = ans; int flag = 0;
				int j = i + 1;
				for ( ; j <= n; j++) {
					if (a[j] == 0)	continue;
					if (j <= ans2 + a[j] + a[i] - 1) {
						ans2 += (a[j] + a[i]);
						flag = 1;
						break;
					}
					ans2 += a[j];
				}
				if (flag == 0)	break;
				else {
					ans = ans2;
					i = j;
				}
			}
		}
		cout << ans << endl;
		memset(a, 0, sizeof(a));
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n,t,f[10005];

int main()
{
    int i,j,cont;
    cin>>t;
    while(t--)
    {
        /*cin>>n;
        v[1]=1;
        n++;
        for(i=2;i<=n;i++)
            cin>>v[i];
        sort(v+1,v+n+1);
        i=1;
        cont=0;
        for(j=2;j<=n;j++)
        {
            cont++;
            while(v[j]==v[j+1] && j+1<=n)
                j++ , cont++;
            if(i+cont>v[j])
                i+=cont , cont=0;
        }
        cout<<i<<'\n';*/
        int i,j,x;
        cin>>n;
        n++;
        for(i=1;i<=n;i++)
            f[i]=0;
        for(i=2;i<=n;i++)
            cin>>x , f[x]++;
        i=1;
        cont=0;
        for(j=1;j<=n;j++)
            if(f[j])
        {
            cont+=f[j];
            if(i+cont>j)
                i+=cont,cont=0;
        }
        cout<<i<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n,t,v[10005];

int main()
{
    int i,j,cont;
    cin>>t;
    while(t--)
    {
        cin>>n;
        v[1]=1;
        n++;
        for(i=2;i<=n;i++)
            cin>>v[i];
        sort(v+1,v+n+1);
        i=1;
        cont=0;
        for(j=2;j<=n;j++)
        {
            cont++;
            while(v[j]==v[j+1] && j+1<=n)
                j++ , cont++;
            if(i+cont>v[j])
                i+=cont , cont=0;
        }
        cout<<i<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n,t,v[10005];

int main()
{
    int i,j,sol;
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(i=1;i<=n;i++)
            cin>>v[i];
        sort(v+1,v+n+1);
        sol=1;
        for(i=1;i<=n;i++)
            if(i>=v[i])
            sol=i+1;
        cout<<sol<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n,t,v[100005];

int main()
{
    int i,j,cont;
    cin>>t;
    while(t--)
    {
        cin>>n;
        v[1]=1;
        n++;
        for(i=2;i<=n;i++)
            cin>>v[i];
        sort(v+1,v+n+1);
        i=1;
        cont=0;
        for(j=2;j<=n;j++)
        {
            cont++;
            while(v[j]==v[j+1] && j+1<=n)
                j++ , cont++;
            if(i+cont>v[j])
                i+=cont , cont=0;
        }
        cout<<i<<'\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long m[900995];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 int t,n,b,c=0,d=0,e,f,g,h,i,j=1,k=1,l=0,u[1000];
   cin>>t;c=0;j=0;
    while(t--)
    {
        cin>>n;memset(m,0,sizeof(m));
        int a[n];c=0;d=1;
       for(i=0;i<n;i++)
       {
           cin>>a[i];
           m[a[i]]++;
           if(m[a[i]]==2)
            c=max(c,a[i]);

       }
       //cout<<c<<endl<<d<<endl;
       sort(a,a+n);
       for(i=0;i<n;i++){
        if(a[i]<=c)
        d++;
        else if(d>=a[i])
        d++;
        else
            break;}
        cout<<d<<endl;

    }
    return 0;}


#include<bits/stdc++.h>
using namespace std;
bitset<65000000>f;
long long m[900995];
vector<long long>y;
//map<long long,long long>c;
map<long long,long long>u1;
map<string,int>v;
string w[200008];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 long long t,n,b,c=0,d=0,e,f,g,h,i,j=1,k=1,l=0,u[1000];
   cin>>t;c=0;j=0;
    while(t--)
    {
        cin>>n;memset(m,0,sizeof(m));
        long long a[n];c=0;d=1;
       for(i=0;i<n;i++)
       {
           cin>>a[i];
           m[a[i]]++;
           if(m[a[i]]==2)
            c=max(c,a[i]);

       }
       //cout<<c<<endl<<d<<endl;
       sort(a,a+n);
       for(i=0;i<n;i++){
        if(a[i]<=c)
        d++;
        else if(d>=a[i])
        d++;
        else
            break;}
        cout<<d<<endl;

    }
    return 0;}


#include<bits/stdc++.h>
using namespace std;
//long long m[900995];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 int t,n,b,c=0,d=0,e,f,g,h,i,j=1,k=1,l=0,u[1000];
   cin>>t;c=0;j=0;
    while(t--)
    {
        cin>>n;
        //memset(m,0,sizeof(m));
        int a[n];c=0;d=1;
       for(i=0;i<n;i++)
       cin>>a[i];
       sort(a,a+n);
       for(i=0;i<n;i++){
            if((i+1)>=a[i])
               d=i+2;
        }
        cout<<d<<endl;

    }
    return 0;}


#include<bits/stdc++.h>
using namespace std;
bitset<65000000>f;
long long m[900995];
long long m1[900995];
vector<long long>y;
//map<long long,long long>c;
map<long long,long long>u1;
map<string,int>v;
string w[200008];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 long long t,n,b,c=0,d=0,e,f,g,h,i,j=1,k=1,l=0,u[1000];
   cin>>t;c=0;j=0;
    while(t--)
    {
        cin>>n;memset(m,0,sizeof(m));
        long long a[n];c=0;d=1;k=0;h=0;g=0;
       for(i=0;i<n;i++)
       {
           cin>>a[i];
           m[a[i]]++;
           if(d>=a[i])
            d++;
           else
            {
                {if(a[i]<(n+2))
                m1[k]=a[i];
           //cout<<k<<endl;
           //cout<<m1[k]<<a[i]<<endl;
           k++;}
           }
          //cout<<d<<endl;
           if(m[a[i]]==2)
           {

               sort(m1,m1+k);
               for(j=h;j<k;j++){
                if(m1[j]<=a[i]){
                        //cout<<m1[j]<<" ";
                d++;}
               else{
                    g=j;
                break;}}
                if(k>0)
                h=min(g,k-1);
           }
           //cout<<d<<endl;

       }
       //cout<<c<<endl<<d<<endl;
      /* sort(a,a+n);
       for(i=0;i<n;i++){
        if(a[i]<=c)
        d++;
        else if(d>=a[i])
        d++;
        else
            break;}*/
        cout<<d<<endl;

    }
    return 0;}


#include<bits/stdc++.h>
using namespace std;
bitset<65000000>f;
long long m[900995];
long long m1[900995];
vector<long long>y;
//map<long long,long long>c;
map<long long,long long>u1;
map<string,int>v;
string w[200008];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 long long t,n,b,c=0,d=0,e,f,g,h,i,j=1,k=1,l=0,u[1000];
   cin>>t;c=0;j=0;
    while(t--)
    {
        cin>>n;memset(m,0,sizeof(m));
        long long a[n];c=0;d=1;k=0;h=0;g=0;
       for(i=0;i<n;i++){
           cin>>a[i];
           m[a[i]]++;
           if(d>=a[i])
            d++;
           else
            {
             if(a[i]<(n+2)){
                m1[k]=a[i];
           k++;}
          if(m[a[i]]>=2)
            c=max(c,a[i]);
           }
       }
      // cout<<c<<endl<<d<<endl;
       sort(m1,m1+k);
       for(i=0;i<k;i++){
        if(m1[i]<=c)
        d++;
        else if(d>=m1[i])
        d++;
        else
            break;}
        cout<<d<<endl;

    }
    return 0;}


#include<bits/stdc++.h>
using namespace std;
long long m[900995];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 int t,n,b,c=0,d=0,e,f,g,h,i,j=1,k=1,l=0,u[1000];
   cin>>t;c=0;j=0;
    while(t--)
    {
        cin>>n;memset(m,0,sizeof(m));
        int a[n];c=0;d=1;
       for(i=0;i<n;i++)
       cin>>a[i];
       sort(a,a+n);
       for(i=0;i<n;i++){
            if((i+1)>=a[i])
               d=i+2;
        }
        cout<<d<<endl;

    }
    return 0;}


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

using namespace std;

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


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

using namespace std;

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


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t-->0)
    {
        long int n,i,ans=0;
        cin>>n;
        long int a[n],c=1;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        if(a[0]>1)
        cout<<c<<endl;
        else
        {
            for(i=0;i<n;i++)
            {
                if(a[i]<=i+1)
                {
                    ans=i+1;
                }
            }
            cout<<ans+c<<endl;
        }
    }
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t-->0)
    {
        long int n,i,ans;
        cin>>n;
        long int a[n],c=1;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        if(a[0]>1)
        cout<<c<<endl;
        else
        {
            for(i=0;i<n;i++)
            {
                if(a[i]<=i+1)
                {
                    ans=i+1;
                }
            }
            cout<<ans+c<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
#define reg register
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
static char buf[100000],*p1=buf,*p2=buf;
inline int read(void){
	reg bool f=false;
	reg char ch=getchar();
	reg int res=0;
	while(ch<'0'||'9'<ch)f|=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')res=10*res+ch-'0',ch=getchar();
	return f?-res:res;
}

const int MAXN=100000+5;

int n;
int a[MAXN];

int main(void){
	reg int T=read();
	while(T--){
		n=read();
		for(reg int i=1;i<=n;++i)
			a[i]=read();
		sort(a+1,a+n+1);
		reg int ans=1;
		for(reg int i=1;i<=n;++i)
			if(a[i]<=i)
				ans=i+1;
		printf("%d\n",ans);
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int a[200050];
int main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		for(int i=1;i<=n;i++)
		{
			cin >> a[i];
		}
		sort(a+1,a+n+1);
		int ans = 1;
		int now = 1;
		for(int i=1;i<=n;i++)
		{
			if(a[i]<=i)
			{
				ans = i + 1;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


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

int a[100001];

int main()
{
    int T;
    scanf("%d", &T);
    while (T--)
    {
        int n, ans = 0;
        scanf("%d", &n);
        for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
        sort(a + 1, a + n + 1);
        for (int i = 1; i <= n; i++)
        if (ans >= a[i] - 1) ans++;
        printf("%d\n", ans);
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		scanf("%d",&n);
		int a[n];
		for(int i=0;i<n;i++)scanf("%d",&a[i]);
		sort(a,a+n);
		int ans=1;
		for(int i=0;i<n;i++){
			if(a[i]<=i+1){
				ans=i+2;
			}
		}
		cout<<ans<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
 long long int B[600000];
int main()
{
    long long int a,b,c,d,e,i,j,k,t,n,m,r;
    cin>>t;
    while(t--)
    {
       cin>>n;
       long long int A[n+5];
       d=0;
       memset(B,0,sizeof(B));
       for(i=0;i<n;i++)
        {
            cin>>A[i];
            B[A[i]]++;
            if(A[i]<=n) d++;
        }
        sort(A,A+n);
        c=1;
        for(i=0;i<n;i++)
        {

                if(c>=A[i]&&B[A[i]]!=0)
                {
                    c+=B[A[i]];
                    B[A[i]]=0;

                }
                else if(c>=2)
                {
                    if(A[i]<=d&&B[A[i]]!=0)
                    {
                        c+=B[A[i]];
                        B[A[i]]=0;
                    }
                }

        }
        cout<<c<<endl;

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
 long long int B[600000];
int main()
{
    long long int a,b,c,d,e,i,j,k,t,n,m,r;
    cin>>t;
    while(t--)
    {
       cin>>n;
       long long int A[n+5];
       d=0;
       memset(B,0,sizeof(B));
       for(i=0;i<n;i++)
        {
            cin>>A[i];
            B[A[i]]++;
            if(A[i]<=n) d++;
        }
        sort(A,A+n);
        c=1;
        for(i=0;i<n;i++)
        {

                if(c>=A[i]&&B[A[i]]!=0)
                {
                    c++;

                }
                else if(c>=2)
                {
                    if(A[i]<=d) c++;
                }

        }
        cout<<c<<endl;

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long int B[600000];
int main()
{
    long long int a,b,c,d,e,i,j,k,t,n,m,r;
    cin>>t;
    while(t--)
    {
        cin>>n;
        long long int A[n+5];
        d=0;

        for(i=1; i<=n; i++)
        {
            cin>>A[i];

        }
        sort(A,A+n+1);
        c=1;
        for(i=n; i>=1; i--)
        {
            if(A[i]<=n&&A[i]<=i){c+=i;break;}

        }
        cout<<c<<endl;

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long int B[600000];
int main()
{
    long long int a,b,c,d,e,i,j,k,t,n,m,r;
    cin>>t;
    while(t--)
    {
        cin>>n;
        long long int A[n+5];
        d=0;

        for(i=1; i<=n; i++)
        {
            cin>>A[i];

        }
        sort(A+1,A+n+1);
        c=1;
        for(i=n; i>=1; i--)
        {
            if(A[i]<=n&&A[i]<=i){c+=i;break;}

        }
        cout<<c<<endl;

    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#define max 10005
using namespace std;
int Count[max];
int a[max];

int main(){
	for(int i=0;i<max;i++){
		Count[i]=i;
	}
	int N;
	scanf("%d",&N);
	while(N--){
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		sort(a+1, a+n+1);
		//for(int i=1;i<=n;i++){
			//printf("%d",a[i]);
		//}
		int x=0;
		for(int i=n;i>=1;i--){
			if(a[i]<=Count[i]){
				x=i;
				break;
			}
		}
		printf("%d\n",x+1);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#define max 10005
using namespace std;
int Count[max];
int a[max];

int main(){
	for(int i=0;i<max;i++){
		Count[i]=i;
	}
	int N;
	scanf("%d",&N);
	while(N--){
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		sort(a, a+n+1);
		//for(int i=1;i<=n;i++){
			//printf("%d",a[i]);
		//}
		int x=0;
		for(int i=n;i>=1;i--){
			if(a[i]<=Count[i]){
				x=i;
				break;
			}
		}
		printf("%d\n",x+1);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#define max 10005
int count[max];
int a[max];

int main(){
		for(int i=0;i<max;i++){
			count[i]=i;
		}
	int N;
	scanf("%d",&N);
	while(N--){
		for(int i=0;i<max;i++){
			a[i]=0;
		}
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		sort(a, a+n+1);
		//for(int i=1;i<=n;i++){
			//printf("%d",a[i]);
		//}
		int x=0;
		for(int i=n;i>=1;i--){
			if(a[i]<=count[i]){
				x=i;
				break;
			}
		}
		printf("%d\n",x+1);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#define max 10005
using namespace std;
int a[max];

int main(){
	int N;
	scanf("%d",&N);
	while(N--){
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		sort(a+1, a+n+1);
		//for(int i=1;i<=n;i++){
			//printf("%d",a[i]);
		//}
		int x=0;
		for(int i=n;i>=1;i--){
			if(a[i]<=i){
				x=i;
				break;
			}
		}
		printf("%d\n",x+1);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#define max 100005
using namespace std;
int a[max];

int main(){
	int N;
	scanf("%d",&N);
	while(N--){
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		sort(a+1, a+n+1);
		//for(int i=1;i<=n;i++){
			//printf("%d",a[i]);
		//}
		int x=0;
		for(int i=n;i>=1;i--){
			if(a[i]<=i){
				x=i;
				break;
			}
		}
		printf("%d\n",x+1);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#define max 10005
using namespace std;
int Count[max];
int a[max];

int main(){
		for(int i=0;i<max;i++){
			Count[i]=i;
		}
	int N;
	scanf("%d",&N);
	while(N--){
		for(int i=0;i<max;i++){
			a[i]=0;
		}
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		sort(a, a+n+1);
		//for(int i=1;i<=n;i++){
			//printf("%d",a[i]);
		//}
		int x=0;
		for(int i=n;i>=1;i--){
			if(a[i]<=Count[i]){
				x=i;
				break;
			}
		}
		printf("%d\n",x+1);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#define max 20005
using namespace std;
int a[max];

int main(){
	int N;
	scanf("%d",&N);
	while(N--){
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		sort(a+1, a+n+1);
		//for(int i=1;i<=n;i++){
			//printf("%d",a[i]);
		//}
		int x=0;
		for(int i=n;i>=1;i--){
			if(a[i]<=i){
				x=i;
				break;
			}
		}
		printf("%d\n",x+1);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<cstdio>
#define max 10005
int count[max];
int a[max];
int sort(int a[],int n){
	for(int i=0;i<n;i++){
		for(int j=0;j<n-1;j++){
			if(a[j] > a[j+1]){
				int temp = a[j];
				a[j] = a[j+1];
				a[j+1] = temp;
			}
		}
	}
}
int main(){
		for(int i=0;i<max;i++){
			count[i]=i;
		}
	int N;
	scanf("%d",&N);
	while(N--){
		for(int i=0;i<max;i++){
			a[i]=0;
		}
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		sort(a, n+1);
		//for(int i=1;i<=n;i++){
			//printf("%d",a[i]);
		//}
		int x=0;
		for(int i=n;i>=1;i--){
			if(a[i]<=count[i]){
				x=i;
				break;
			}
		}
		printf("%d\n",x+1);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<cstdio>
#define max 10005
int count[max];
int a[max];
int sort(int a[],int n){
	for(int i=0;i<n;i++){
		for(int j=0;j<n-1;j++){
			if(a[j] > a[j+1]){
				int temp = a[j];
				a[j] = a[j+1];
				a[j+1] = temp;
			}
		}
	}
}
int main(){
		for(int i=0;i<max;i++){
			count[i]=i;
		}
	int N;
	scanf("%d",&N);
	while(N--){
		for(int i=0;i<max;i++){
			a[i]=0;
		}
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		sort(a, n);
		//for(int i=1;i<=n;i++){
			//printf("%d",a[i]);
		//}
		int x=0;
		for(int i=n;i>=1;i--){
			if(a[i]<=count[i]){
				x=i;
				break;
			}
		}
		printf("%d\n",x+1);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define u unsigned
#define N1 100005
#define N2 200005
#define endl "\n"
#define mod 1000000007
#define vll vector<ll>
#define pb push_back
#define cy cout<<"YES\n"
#define cn cout<<"NO\n"

int main()
{
    ll t,n,m,a,b,ar[N1];
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=0;i<n;i++) cin>>ar[i];
        sort(ar,ar+n);
        int cnt=0,no=1;
        for(int i=0;i<n;)
        {
            if(no>=ar[i])
            {
                no+=1;
                i++;
            }
            else
            {
                i++;
                int c=ar[i-1]-no;
                int te=0;
                while(i<n&&c)
                {
                    if(ar[i]-ar[i-1]==0) c--;
                    else
                    {
                        c+=ar[i]-ar[i-1]-1;
                    }
                    i++;
                    te+=1;
                }
                if(i<n&&c==0) no+=te+1;

            }

        }
        cout<<no<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define u unsigned
#define N1 100005
#define N2 200005
#define endl "\n"
#define mod 1000000007
#define vll vector<ll>
#define pb push_back
#define cy cout<<"YES\n"
#define cn cout<<"NO\n"

int main()
{
    ll t,n,m,a,b,ar[N1];
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=0;i<n;i++) cin>>ar[i];
        sort(ar,ar+n);
        int cnt=0,no=1;
        for(int i=0;i<n;i++)
        {
            if(i+1>=ar[i])
            cnt=i+1;
        }
        cout<<cnt+1<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define u unsigned
#define N1 100005
#define N2 200005
#define endl "\n"
#define mod 1000000007
#define vll vector<ll>
#define pb push_back
#define cy cout<<"YES\n"
#define cn cout<<"NO\n"

int main()
{
    ll t,n,m,a,b,ar[N1];
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=0;i<n;i++) cin>>ar[i];
        sort(ar,ar+n);
        int cnt=0,no=1;
        for(int i=0;i<n;i++)
        {
            if(no>=ar[i])
            {
                no+=1;
            }
            else
            {
                int c=ar[i]-no;
                int te=0;
                while(i<n-1&&c+((ar[i+1]-ar[i])<=1))
                {
                    // cout<<"loop"<<ar[i]<<" "<<ar[i+1]<<"end;";
                    te+=1;
                    c--;
                    if(c<0)c=0;
                    i++;
                    // cout<<"I:"<<i;
                }
                if(i<n-1) no+=te+1;
            }

        }
        cout<<no<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define u unsigned
#define N1 100005
#define N2 200005
#define endl "\n"
#define mod 1000000007
#define vll vector<ll>
#define pb push_back
#define cy cout<<"YES\n"
#define cn cout<<"NO\n"

int main()
{
    ll t,n,m,a,b,ar[N1];
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=0;i<n;i++) cin>>ar[i];
        sort(ar,ar+n);
        int cnt=0,no=1;
        for(int i=0;i<n;i++)
        {
            if(no>=ar[i])
            {
                no+=1;
            }
            else
            {
                i++;
                int c=ar[i-1]-no;
                int te=0;
                while(i<n&&c)
                {
                    if(ar[i]-ar[i-1]==0) c--;
                    else
                    {
                        c+=ar[i]-ar[i-1]-1;
                    }
                    i++;
                    te+=1;
                }
                if(i<n&&c==0) no+=te+1;
            }

        }
        cout<<no<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int pr[200005];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t; cin>>t;
	int n;
	while(t--)
	{ int f[200005]={0};
	  cin>>n;
	  int k; int m=-1;
	  for(int i=0;i<=n-1;i++)
	  {
	  	cin>>k;
	  	f[k]++;
	  	m=max(m,k);
	  }
	  if(n==1)
	  {
	  	if(a[0]==1)
	  	cout<<2<<"\n";
	  	else
	  	cout<<1<<"\n";
	  	continue;
	  }
	  pr[1]=f[1];
	  for(int i=2;i<=m;i++)
	  pr[i]=pr[i-1]+f[i];
	  int l=0;
	  for(int i=m;i>=1;i--)
	  {
	    if(pr[i]>=i)
		{
			l=pr[i];
			break;
		}
	  }
	  cout<<l+1<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int pr[200005];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int t; cin>>t;
	int n;
	while(t--)
	{ int f[200005]={0};
	  cin>>n;
	  int k; int m=-1;
	  for(int i=0;i<=n-1;i++)
	  {
	  	cin>>k;
	  	f[k]++;
	  	m=max(m,k);
	  }
	  pr[1]=f[1];
	  for(int i=2;i<=m;i++)
	  pr[i]=pr[i-1]+f[i];
	  int l=0;
	  for(int i=m;i>=1;i--)
	  {
	    if(pr[i]>=i)
		{
			l=pr[i];
			break;
		}
	  }
	  cout<<l+1<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t,n; cin>>t;
    while(t--)
    {
        cin>>n;
        int f[200005];
        memset(f,0,sizeof(f));
        int k; int m=-1;
        for(int i=0;i<=n-1;i++)
        {
            cin>>k;
            f[k]++;
            m=max(k,m);
        }
        int pr[200005];
        pr[1]=f[1];
        for(int i=2;i<=m;i++)
            pr[i]=pr[i-1]+f[i];
        int l;
        for(int i=m;i>=1;i--)
        {
            if(pr[i]-i>=0)
            {
                l=pr[i];
                break;
            }
        }
        cout<<l+1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t; cin>>t;
    while(t--)
    {
        int n; cin>>n;
        int c1=0;
        vector<int>a(n);
        vector<ll>f(200004,0);
        int m=-1;
        for(int i=0;i<=n-1;i++)
        {
            cin>>a[i];
            if(a[i]==1)
                c1++;
            f[a[i]]++;
            m=max(a[i],m);
        }
        if(c1==0)
        {
            cout<<1<<"\n";
            continue;
        }
        vector<ll>pr(200005,0);
        pr[1]=f[1];
        for(int i=2;i<=m;i++)
            pr[i]=pr[i-1]+f[i];
        ll l=0;
        for(int i=m;i>=1;i--)
         {
            if(pr[i]>=i)
            {
                l=pr[i];
                break;
            }
         }
         cout<<l+1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t; cin>>t;
    while(t--)
    {
        int n; cin>>n;
        int c1=0;
        vector<int>a(n);
        vector<int>f(200004,0);
        int m=-1;
        for(int i=0;i<=n-1;i++)
        {
            cin>>a[i];
            if(a[i]==1)
                c1++;
            f[a[i]]++;
            m=max(a[i],m);
        }
        if(n==1)
        {
            if(a[0]==1)
                cout<<2<<"\n";
            else
                cout<<1<<"\n";
            continue;
        }
        if(c1==0)
        {
            cout<<1<<"\n";
            continue;
        }
        vector<int>pr(200005,0);
        pr[1]=f[1];
        for(int i=2;i<=m;i++)
            pr[i]=pr[i-1]+f[i];
        int l=0;
        for(int i=m;i>=1;i--)
         {
            if(pr[i]>=i)
            {
                l=pr[i];
            }
         }
         cout<<l+1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int f[200004],pr[200004];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    memset(f,0,sizeof(f));
    int t; cin>>t;
    while(t--)
    {   memset(f,0,sizeof(f));
        int n; cin>>n;
        int c1=0;
        vector<int>a(n);
        int m=-1;
        for(int i=0;i<=n-1;i++)
        {
            cin>>a[i];
            if(a[i]==1)
                c1++;
            f[a[i]]++;
            m=max(a[i],m);
        }
        if(n==1)
        {
            if(a[0]==1)
                cout<<2<<"\n";
            else
                cout<<1<<"\n";
            continue;
        }
        if(c1==0)
        {
            cout<<1<<"\n";
            continue;
        }
        pr[1]=f[1];
        for(int i=2;i<=m;i++)
            pr[i]=pr[i-1]+f[i];
        int l=0;
        for(int i=m;i>=1;i--)
         {
            if(pr[i]>=i)
            {
                l=pr[i];
                break;
            }
         }
         cout<<l+1<<"\n";
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

#define REP(AA,BB) for(int AA=0; AA<(BB); ++AA)
#define FOR(AA,BB,CC) for(int AA=(BB); AA<(CC); ++AA)
#define FC(AA,BB) for(__typeof((AA).begin()) BB=(AA).begin(); BB!=(AA).end(); ++BB)
#define SZ(AA) ((int)((AA).size()))
#define ALL(AA) (AA).begin(), (AA).end()
#define PB push_back
#define MP make_pair

using namespace std;

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long LL;
typedef long double LD;

const int MAXN = 200010;

double P[1 << 20]; double X[1 << 20]; double c;
double mn[1 << 20], mx[1 << 20], w[1 << 20];
int BASE;

void build() {
    for (int i = BASE; i < 2 * BASE; ++i) {
        mn[i] = mx[i] = X[i - BASE] * 0.5 - c * P[i - BASE];
        w[i] = 0;
    }
    for (int i = BASE - 1; i > 0; --i) {
        mn[i] = min(mn[i * 2], mn[i * 2 + 1]);
        mx[i] = max(mx[i * 2], mx[i * 2 + 1]);
        w[i] = max(max(w[i * 2], w[i * 2 + 1]), mx[i * 2 + 1] - mn[i * 2]);
    }
}

struct wyn {
    double mn, mx, best;
};

wyn get(int a, int b, int x, int y, int p) {
    wyn res;
    if (a == x && b == y) {
        res.mn = mn[p];
        res.mx = mx[p];
        res.best = w[p];
        return res;
    }
    int mid = (x + y) / 2;
    if (b <= mid)
        return get(a, b, x, mid, 2 * p);
    else if (a > mid)
        return get(a, b, mid + 1, y, 2 * p + 1);
    else {
        wyn e = get(a, mid, x, mid, 2 * p);
        wyn f = get(mid + 1, b, mid + 1, y, 2 * p + 1);
        res.mn = min(e.mn, f.mn);
        res.mx = max(e.mx, f.mx);
        res.best = max(max(e.best, f.best), f.mx - e.mn);
    }
    return res;
}

int main(void) {
    int n, m; scanf("%d%d%lf", &n, &m, &c);
    REP (i, n)
        scanf("%lf", &X[i]);
    P[0] = 0.0;
    FOR (i, 1, n) {
        scanf("%lf", &P[i]);
        P[i] = 0.01 * P[i];
        P[i] += P[i - 1];
    }
    for (BASE = 1; BASE < n; BASE <<= 1);
    for (int i = n; i < BASE; ++i) {
        P[i] = P[n - 1];
        X[i] = X[n - 1];
    }
    build();
    double res = 0.0;
    REP (i, m) {
        int a, b; scanf("%d%d", &a, &b);
        --a; --b;
        res += get(a, b, 0, BASE - 1, 1).best;
    }
    printf("%.10lf\n", res);
    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <memory.h>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define Forn(i, n) for (int i = 0; i < (n); i++)
#define Fornr(i, n) for (int i = (n) - 1; i > -1; i--)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define Forr(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define fill(a, b) memset((a), (b), sizeof((a)))
#define pb push_back
#define inf 2147483647
#define N 150100

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

struct node
{
    double s, l, r, m;
    node() {}
    node(double v)
    {
        s = v;
        l = r = m = max(0.0, v);
    }
};

node t[4 * N];
int n, m, c, x[N];
double a[N];

node unite(node a, node b)
{
    node res;
    res.s = a.s + b.s;
    res.l = max(a.l, a.s + b.l);
    res.r = max(b.r, b.s + a.r);
    res.m = max(max(a.m, b.m), a.r + b.l);
    return res;
}

void build(int v, int l, int r)
{
    if (l == r)
        t[v] = node(a[l]);
    else
    {
        int m = (l + r) >> 1;
        build(2 * v, l, m);
        build(2 * v + 1, m + 1, r);
        t[v] = unite(t[2 * v], t[2 * v + 1]);
    }
}

node calc(int v, int tl, int tr, int l, int r)
{
    if (l == tl && r == tr)
        return t[v];
    int tm = (tl + tr) >> 1;
    if (r <= tm)
        return calc(2 * v, tl, tm, l, r);
    if (l > tm)
        return calc(2 * v + 1, tm + 1, tr, l, r);
    return unite(calc(2 * v, tl, tm, l, tm), calc(2 * v + 1, tm + 1, tr, tm + 1, r));
}

int main()
{
#ifdef LocalHost
    freopen("in", "r", stdin);
//    freopen("out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &c);
    Forn(i, n) scanf("%d", &x[i]);
    n--;
    Forn(i, n)
    {
        int v;
        scanf("%d", &v);
        a[i + 1] = (x[i + 1] - x[i]) / 2.0 - v / 100.0 * c;
    }
    build(1, 1, n);
    double ans = 0;
    Forn(i, m)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        ans += max(0.0, calc(1, 1, n, l, r - 1).m);
    }
    printf("%.7lf", ans);
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <memory.h>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define Forn(i, n) for (int i = 0; i < (n); i++)
#define Fornr(i, n) for (int i = (n) - 1; i > -1; i--)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define Forr(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define fill(a, b) memset((a), (b), sizeof((a)))
#define pb push_back
#define inf 2147483647
#define N 150100

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

struct node
{
    double s, l, r, m;
    node() {}
    node(double v)
    {
        s = v;
        l = r = m = max(0.0, v);
    }
};

node t[4 * N];
int n, m, c, x[N];
double a[N];

node unite(node a, node b)
{
    node res;
    res.s = a.s + b.s;
    res.l = max(a.l, a.s + b.l);
    res.r = max(b.r, b.s + a.r);
    res.m = max(max(a.m, b.m), a.r + b.l);
    return res;
}

node build(int v, int l, int r)
{
    if (l == r)
        t[v] = node(a[l]);
    else
    {
        int m = (l + r) >> 1;
        build(2 * v, l, m);
        build(2 * v + 1, m + 1, r);
        t[v] = unite(t[2 * v], t[2 * v + 1]);
    }
}

node calc(int v, int tl, int tr, int l, int r)
{
    if (l == tl && r == tr)
        return t[v];
    int tm = (tl + tr) >> 1;
    if (r <= tm)
        return calc(2 * v, tl, tm, l, r);
    if (l > tm)
        return calc(2 * v + 1, tm + 1, tr, l, r);
    return unite(calc(2 * v, tl, tm, l, tm), calc(2 * v + 1, tm + 1, tr, tm + 1, r));
}

int main()
{
#ifdef LocalHost
    freopen("in", "r", stdin);
//    freopen("out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &c);
    Forn(i, n) scanf("%d", &x[i]);
    n--;
    Forn(i, n)
    {
        int v;
        scanf("%d", &v);
        a[i + 1] = (x[i + 1] - x[i]) / 2.0 - v / 100.0 * c;
    }
    build(1, 1, n);
    double ans = 0;
    Forn(i, m)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        ans += max(0.0, calc(1, 1, n, l, r - 1).m);
    }
    printf("%.7lf", ans);
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <memory.h>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define Forn(i, n) for (int i = 0; i < (n); i++)
#define Fornr(i, n) for (int i = (n) - 1; i > -1; i--)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define Forr(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define fill(a, b) memset((a), (b), sizeof((a)))
#define pb push_back
#define inf 2147483647
#define N 100100

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

struct node
{
    double s, l, r, m;
    node() {}
    node(double v)
    {
        s = v;
        l = r = m = max(0.0, v);
    }
};

node t[4 * N];
int n, m, c, x[N];
double a[N];

node unite(node a, node b)
{
    node res;
    res.s = a.s + b.s;
    res.l = max(a.l, a.s + b.l);
    res.r = max(b.r, b.s + a.r);
    res.m = max(max(a.m, b.m), a.r + b.l);
    return res;
}

node build(int v, int l, int r)
{
    if (l == r)
        t[v] = node(a[l]);
    else
    {
        int m = (l + r) >> 1;
        build(2 * v, l, m);
        build(2 * v + 1, m + 1, r);
        t[v] = unite(t[2 * v], t[2 * v + 1]);
    }
}

node calc(int v, int tl, int tr, int l, int r)
{
    if (l == tl && r == tr)
        return t[v];
    int tm = (tl + tr) >> 1;
    if (r <= tm)
        return calc(2 * v, tl, tm, l, r);
    if (l > tm)
        return calc(2 * v + 1, tm + 1, tr, l, r);
    return unite(calc(2 * v, tl, tm, l, tm), calc(2 * v + 1, tm + 1, tr, tm + 1, r));
}

int main()
{
#ifdef LocalHost
    freopen("in", "r", stdin);
//    freopen("out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &c);
    Forn(i, n) scanf("%d", &x[i]);
    n--;
    Forn(i, n)
    {
        int v;
        scanf("%d", &v);
        a[i + 1] = (x[i + 1] - x[i]) / 2.0 - v / 100.0 * c;
    }
    build(1, 1, n);
    double ans = 0;
    Forn(i, m)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        ans += max(0.0, calc(1, 1, n, l, r - 1).m);
    }
    printf("%.7lf", ans);
}


 * 线段树，对于每个乘客，求区间[a, b-1]的最大字段和
 */
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define lson(t) ((t) << 1)
#define rson(t) (((t) << 1) | 1)
#define maxn 155555

struct Nod {
    int l, r;
    double maxL, maxR, sum, Max;
}T[maxn << 2];
int N, M;
double C;
double x[maxn], p[maxn], a[maxn];

void pushUp(int rt) {
    T[rt].sum = T[lson(rt)].sum + T[rson(rt)].sum;
    T[rt].maxL = max(T[lson(rt)].maxL, T[lson(rt)].sum + T[rson(rt)].maxL);
    T[rt].maxR = max(T[rson(rt)].maxR, T[lson(rt)].maxR + T[rson(rt)].sum);
    T[rt].Max = max(max(T[lson(rt)].Max, T[rson(rt)].Max), T[lson(rt)].maxR + T[rson(rt)].maxL);
}

void build(int l, int r, int rt) {
    T[rt].l = l; T[rt].r = r;
    if (l == r) {
        T[rt].sum = a[r];
        T[rt].Max = max(0.0, a[r]);
        T[rt].maxL = T[rt].maxR = T[rt].Max;
        return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, lson(rt));
    build(mid + 1, r, rson(rt));
    pushUp(rt);
}

Nod query(int L, int R, int rt) {
    if (L <= T[rt].l && T[rt].r <= R) {
        return T[rt];
    }
    int mid = (T[rt].l + T[rt].r) >> 1;
    if (R <= mid) return query(L, R, lson(rt));
    else if (L > mid) return query(L, R, rson(rt));
    else {
        Nod ll = query(L, mid, lson(rt));
        Nod rr = query(mid + 1, R, rson(rt));
        Nod tmp;
        tmp.sum = ll.sum + rr.sum;
        tmp.maxL = max(ll.maxL, ll.sum + rr.maxL);
        tmp.maxR = max(rr.maxR, rr.sum + ll.maxR);
        tmp.Max = max(max(ll.Max, rr.Max), ll.maxR + rr.maxL);
        return tmp;
    }
}

int main() {
//    freopen("in", "r", stdin);
    cin >> N >> M >> C;
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    for (int i = 1; i < N; i++) {
        cin >> p[i];
        a[i] = (x[i] - x[i - 1]) * 0.5 - C * p[i] / 100.0;
    }
    build(1, N - 1, 1);
    double ret = 0.0;
    while (M--) {
        int x, y;
        cin >> x >> y;
        double tmp = query(x, y - 1, 1).Max;
        if (tmp > 0) ret += tmp;
    }
    printf("%.8lf\n", ret);
    return 0;
}


/*
 * 线段树，对于每个乘客，求区间[a, b-1]的最大字段和
 */
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define lson(t) ((t) << 1)
#define rson(t) (((t) << 1) | 1)
#define maxn 155555

struct Nod {
    int l, r;
    double maxL, maxR, sum, Max;
}T[maxn << 2];
int N, M;
double C;
double x[maxn], p[maxn], a[maxn];

void pushUp(int rt) {
    T[rt].sum = T[lson(rt)].sum + T[rson(rt)].sum;
    T[rt].maxL = max(T[lson(rt)].maxL, T[lson(rt)].sum + T[rson(rt)].maxL);
    T[rt].maxR = max(T[rson(rt)].maxR, T[lson(rt)].maxR + T[rson(rt)].sum);
    T[rt].Max = max(max(T[lson(rt)].Max, T[rson(rt)].Max), T[lson(rt)].maxR + T[rson(rt)].maxL);
}

void build(int l, int r, int rt) {
    T[rt].l = l; T[rt].r = r;
    if (l == r) {
        T[rt].sum = a[r];
        T[rt].Max = max(0.0, a[r]);
        T[rt].maxL = T[rt].maxR = T[rt].Max;
        return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, lson(rt));
    build(mid + 1, r, rson(rt));
    pushUp(rt);
}

Nod query(int L, int R, int rt) {
    if (L <= T[rt].l && T[rt].r <= R) {
        return T[rt];
    }
    int mid = (T[rt].l + T[rt].r) >> 1;
    if (R <= mid) return query(L, R, lson(rt));
    else if (L > mid) return query(L, R, rson(rt));
    else {
        Nod ll = query(L, mid, lson(rt));
        Nod rr = query(mid + 1, R, rson(rt));
        Nod tmp;
        tmp.sum = ll.sum + rr.sum;
        tmp.maxL = max(ll.maxL, ll.sum + rr.maxL);
        tmp.maxR = max(rr.maxR, rr.sum + ll.maxR);
        tmp.Max = max(max(ll.Max, rr.Max), ll.maxR + rr.maxL);
        return tmp;
    }
}

int main() {
//    freopen("in", "r", stdin);
    cin >> N >> M >> C;
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    for (int i = 1; i < N; i++) {
        cin >> p[i];
        a[i] = (x[i] - x[i - 1]) * 0.5 - C * p[i] / 100.0;
    }
    build(1, N - 1, 1);
    double ret = 0.0;
    while (M--) {
        int x, y;
        cin >> x >> y;
        double tmp = query(x, y - 1, 1).Max;
        if (tmp > 0) ret += tmp;
    }
    printf("%.8lf\n", ret);
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

const int maxn=150000;
const double eps=1e-9;

#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1

int n,m;

double prev[maxn+1],ans,x[maxn+1],p[maxn+1],d[maxn+1],c,rm[maxn<<2|1],lm[maxn<<2|1],tol[maxn<<2|1],v[maxn+1],sum[maxn<<2|1];

struct now_state
{
	double max,lm,rm,sum;
	now_state()
	{
		max=lm=rm=sum=0;
	}
}nowans;

void update(int rt)
{
	int l=rt<<1,r=rt<<1|1;
	if (fabs(lm[l]-sum[l])<=eps) lm[rt]=max(lm[l]+lm[r],lm[l]);
	else lm[rt]=lm[l];
	if (fabs(rm[r]-sum[r])<=eps) rm[rt]=max(rm[r]+rm[l],rm[r]);
	else rm[rt]=rm[r];
	tol[rt]=max(max(max(max(tol[l],tol[r]),rm[l]+lm[r]),lm[rt]),rm[rt]);
	sum[rt]=sum[l]+sum[r];
}

void buildtree(int l,int r,int rt)
{
	if (l==r)
	{
		v[l]=d[l]*0.5-p[l]*c;
		lm[rt]=rm[rt]=tol[rt]=max(0.0,v[l]);
		return;
	}
	int m=(l+r)>>1;
	buildtree(lson);
	buildtree(rson);
	update(rt);
}

/*double getans(int l,int r,int rt,int nowl,int nowr)
{
	if ((nowl<=l) && (r<=nowr)) return tol[rt];
	int m=(l+r)>>1;
	double ans1=0,ans2=0;
	if (nowl<=m) ans1=getans(lson,nowl,nowr);
	if (m<nowr) ans2=getans(rson,nowl,nowr);
	double ans=max(ans1,ans2);
	if (fabs(ans1)<=eps || fabs(ans2)<=eps) return ans;
	double lmax=0,rmax=0,nowsum=0;
	for (int a=m;a>=nowl;a--)
	{
		nowsum+=v[a];
		lmax=max(lmax,nowsum);
	}
	nowsum=0;
	for (int a=m+1;a<=nowr;a++)
	{
		nowsum+=v[a];
		rmax=max(rmax,nowsum);
	}
	return max(ans,lmax+rmax);
}*/

void getans(int l,int r,int rt,int nowl,int nowr)
{
	if ((nowl<=l) && (r<=nowr))
	{
		if (tol[rt]!=0)
		{
			nowans.max=max(nowans.max,max(nowans.rm+lm[rt],tol[rt]));
			nowans.rm=max(nowans.rm,nowans.rm+prev[r]-prev[l-1]);
			nowans.lm=max(nowans.lm,nowans.sum+lm[rt]);
			nowans.sum+=prev[r]-prev[l-1];
		}
		else
		{
			nowans.max=tol[rt];
			nowans.lm=lm[rt];
			nowans.rm=rm[rt];
			nowans.sum=prev[r]-prev[l-1];
		}
		return;
	}
	int m=(l+r)>>1;
	if (nowl<=m) getans(lson,nowl,nowr);
	if (m<nowr) getans(rson,nowl,nowr);
}

int main()
{
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	scanf("%d%d%lf",&n,&m,&c);
	for (int a=0;a<n;a++)
		scanf("%lf",&x[a]);
	for (int a=1;a<n;a++)
		d[a]=x[a]-x[a-1];
	for (int a=1;a<n;a++)
		scanf("%lf",&p[a]),p[a]/=100.0;
	for (int a=1;a<n;a++)
		prev[a]=prev[a-1]+v[a];
	buildtree(1,n-1,1);
	for (int a=1;a<=m;a++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		nowans.max=nowans.lm=nowans.rm=nowans.sum=0;
		getans(1,n-1,1,l,r-1);
		ans+=nowans.max;
	}
	printf("%lf\n",ans);

	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1

const int maxn=150001;
const double eps=1e-8;

int n,m;

double ans,c,x[maxn],p[maxn],v[maxn],d[maxn];

struct point
{
	double lmax,rmax,max,sum;
	point()
	{
		lmax=rmax=max=sum=0.0;
	}
}z[maxn<<2|1];

void update(int rt)
{
	int l=rt<<1,r=rt<<1|1;
	z[rt].sum=z[l].sum+z[r].sum;
	z[rt].lmax=max(z[l].lmax,z[l].sum+z[r].lmax);
	z[rt].rmax=max(z[r].rmax,z[r].sum+z[l].rmax);
	z[rt].max=max(z[l].max,max(z[r].max,z[l].rmax+z[r].lmax));
}

void buildtree(int l,int r,int rt)
{
	if (l==r)
	{
		z[rt].sum=z[rt].lmax=z[rt].rmax=z[rt].max=v[l];
		return;
	}
	int m=(l+r)>>1;
	buildtree(lson);
	buildtree(rson);
	update(rt);
}

point query(int l,int r,int rt,int nowl,int nowr)
{
	if ((nowl<=l) && (r<=nowr)) return z[rt];
	int m=(l+r)>>1;
	point a,b;
	if (nowl<=m) a=query(lson,nowl,nowr);
	if (m<nowr) b=query(rson,nowl,nowr);
	if ((nowl<=m) && (m<nowr))
	{
		point ans;
		ans.sum=a.sum+b.sum;
		ans.lmax=max(a.lmax,a.sum+b.lmax);
		ans.rmax=max(b.rmax,b.sum+a.rmax);
		ans.max=max(a.max,max(b.max,a.rmax+b.lmax));
		return ans;
	}
	else
	{
		if (nowl<=m) return a;
		else return b;
	}
}

int main()
{
	scanf("%d%d%lf",&n,&m,&c);
	for (int a=0;a<n;a++)
		scanf("%lf",&x[a]);
	for (int a=1;a<n;a++)
		scanf("%lf",&p[a]),p[a]/=100.0;
	for (int a=1;a<n;a++)
		d[a]=x[a]-x[a-1];
	for (int a=1;a<n;a++)
		if (fabs(c-1.0)>eps) v[a]=d[a]*0.5-p[a]*c;
		else v[a]=-c;
	buildtree(1,n-1,1);
	for (int a=1;a<=m;a++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		ans+=max(0.0,query(1,n-1,1,l,r-1).max);
	}
	printf("%lf\n",ans);

	return 0;
}


#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<double> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define MOD 1000000007
#define EPS 1e-10
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(i,x.size())printf("%d%c",x[i],i+1==x.size()?'\n':' ');

int N,M,C;
int X[160000];
double P;
struct Node
{
    double lmx,rmx,sum,val;
    Node(){}
    Node(double lmx,double rmx,double sum,double val):lmx(lmx),rmx(rmx),sum(sum),val(val){}
};
Node mc(Node n1,Node n2)
{
    if(n1.lmx<-1)return n2;
    if(n2.lmx<-1)return n1;
    Node res;
    res.lmx=max(n1.lmx,n1.sum+n2.lmx);
    res.rmx=max(n1.rmx+n2.sum,n2.rmx);
    res.sum=n1.sum+n2.sum;
    res.val=max(max(n1.val,n2.val),n1.rmx+n2.lmx);
    return res;
}
const int n=1<<18;
Node dat[n*2-1];
Node query(int a,int b,int k,int l,int r)
{
    if(r<=a||b<=l)return Node(-111,0,0,0);
    if(a<=l&&r<=b)return dat[k];
    return mc(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
}

int main()
{
    scanf("%d%d%d",&N,&M,&C);
    rep(i,N)scanf("%d",&X[i]);
    rep(i,N-1)
    {
        scanf("%lf",&P),P/=100;P=1.0-P;
        double rr=double(X[i+1]-X[i])/2-(1.0-P)*C;
        dat[n-1+i]=Node(max(rr,0.0),max(rr,0.0),rr,max(rr,0.0));
    }
    double res=0.0;
    for(int i=n-2;i>=0;i--)dat[i]=mc(dat[i*2+1],dat[i*2+2]);
    while(M--)
    {
        scanf("%d%d",&N,&C);N--;C--;
        res+=query(N,C,0,0,n).val;
    }

    printf("%.12f\n",res);
}


#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<double> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define MOD 1000000007
#define EPS 1e-10
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(i,x.size())printf("%d%c",x[i],i+1==x.size()?'\n':' ');

int N,M,C;
int X[160000];
double P;
struct Node
{
    double lmx,rmx,sum,val;
    Node(){}
    Node(double lmx,double rmx,double sum,double val):lmx(lmx),rmx(rmx),sum(sum),val(val){}
};
Node mc(Node n1,Node n2)
{
    if(n1.lmx<-1e29)return n2;
    if(n2.lmx<-1e29)return n1;
    Node res;
    res.lmx=max(n1.lmx,n1.sum+n2.lmx);
    res.rmx=max(n1.rmx+n2.sum,n2.rmx);
    res.sum=n1.sum+n2.sum;
    res.val=max(max(n1.val,n2.val),n1.rmx+n2.lmx);
    return res;
}
const int n=1<<18;
Node dat[n*2-1];
Node query(int a,int b,int k,int l,int r)
{
    if(r<=a||b<=l)return Node(-1e30,0,0,0);
    if(a<=l&&r<=b)return dat[k];
    return mc(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
}

int main()
{
    scanf("%d%d%d",&N,&M,&C);
    rep(i,N)scanf("%d",&X[i]);
    rep(i,N-1)
    {
        scanf("%lf",&P),P/=100;P=1.0-P;
        double rr=(X[i+1]-X[i])/2-(1.0-P)*C;
        dat[n-1+i]=Node(max(rr,0.0),max(rr,0.0),rr,max(rr,0.0));
    }
    double res=0.0;
    for(int i=n-2;i>=0;i--)dat[i]=mc(dat[i*2+1],dat[i*2+2]);
    while(M--)
    {
        scanf("%d%d",&N,&C);N--;C--;
        res+=query(N,C,0,0,n).val;
    }

    printf("%.12f\n",res);
}


#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<double> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define MOD 1000000007
#define EPS 1e-10
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(i,x.size())printf("%d%c",x[i],i+1==x.size()?'\n':' ');

int N,M,C;
int X[160000];
double P;
struct Node
{
    double lmx,rmx,sum,val;
    Node(){}
    Node(double lmx,double rmx,double sum,double val):lmx(lmx),rmx(rmx),sum(sum),val(val){}
};
Node mc(Node n1,Node n2)
{
    if(n1.lmx<-1)return n2;
    if(n2.lmx<-1)return n1;
    Node res;
    res.lmx=max(n1.lmx,n1.sum+n2.lmx);
    res.rmx=max(n1.rmx+n2.sum,n2.rmx);
    res.sum=n1.sum+n2.sum;
    res.val=max(max(n1.val,n2.val),n1.rmx+n2.lmx);
    return res;
}
const int n=1<<18;
Node dat[n*2-1];
Node query(int a,int b,int k,int l,int r)
{
    if(r<=a||b<=l)return Node(-111,0,0,0);
    if(a<=l&&r<=b)return dat[k];
    return mc(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
}

int main()
{
    scanf("%d%d%d",&N,&M,&C);
    rep(i,N)scanf("%d",&X[i]);
    rep(i,N-1)
    {
        scanf("%lf",&P),P/=100;P=1.0-P;
        double rr=(X[i+1]-X[i])/2-(1.0-P)*C;
        dat[n-1+i]=Node(max(rr,0.0),max(rr,0.0),rr,max(rr,0.0));
    }
    double res=0.0;
    for(int i=n-2;i>=0;i--)dat[i]=mc(dat[i*2+1],dat[i*2+2]);
    while(M--)
    {
        scanf("%d%d",&N,&C);N--;C--;
        res+=query(N,C,0,0,n).val;
    }

    printf("%.12f\n",res);
}


/*
 * 150C_107.cpp
 *
 *  Created on: Jan 29, 2013
 *      Author: shuo
 */

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 150011;

int L[N<<2], R[N<<2];
double lv[N<<2], rv[N<<2];
double sum[N<<2], ma[N<<2];

inline int lc(int x) {return x<<1;}
inline int rc(int x) {return x<<1|1;}

typedef struct node {
	double ma, ml, mr;
}qtype;

int cnt[N<<2];
double a[N], pr[N];
int v[N], n;
int c;

void build (int u, int x, int y) {
	L[u] = x; R[u] = y;
	if (x == y) {
		sum[u] = lv[u] = rv[u] = a[x];
		ma[u] = max (a[x], .0);
		return;
	}
	int mid = (x + y) / 2;
	build (u << 1, x, mid);
	build (u << 1 | 1, mid + 1, y);
	sum[u] = sum[u<<1] + sum[u<<1|1];
	ma[u] = max (max (ma[lc(u)], ma[rc(u)]),lv[rc(u)] + rv[lc(u)]);
	lv[u] = max (lv[u<<1], sum[u<<1] + lv[u<<1|1]);
	rv[u] = max (rv[u<<1|1], sum[u<<1|1] + rv[u<<1]);

}

// maximum consecutive sub-block
qtype query (int u, int x, int y) {
	if (x <= L[u] && y >= R[u]) {
		qtype ret = {ma[u], lv[u], rv[u]};
		return ret;
	}
	int mid = (L[u] + R[u]) / 2;
	qtype a = {-1e20, -1e20, -1e20}, b = {-1e20, -1e20, -1e20}, ret;
	if (x <= mid) a = query (u<<1, x, y);
	if (y > mid) b = query (u<<1|1, x, y);
	ret.ma = max(a.ma, b.ma);
	if (x <= mid && y > mid) {
		ret.ma = max (ret.ma, a.mr + b.ml);
	}
	ret.ml = a.ml;
	if (x <= L[u] && y > mid)
		ret.ml = max (ret.ml, sum[u<<1] + b.ml);
	ret.mr = b.mr;
	if (y >= R[u] && x <= mid)
		ret.mr = max (ret.mr, sum[u<<1|1] + a.mr);

	return ret;
}

int main () {
	int i, j, k, m;
	scanf ("%d%d%d", &n, &m, &c);
	for (i = 1, k = 0; i <= n; ++i) {
		scanf ("%d", &v[i]);
		j = v[i] - k;
		k= v[i]; v[i] = j;
	}

	for (i = 2; i <= n; ++i) {
		scanf ("%lf", &pr[i]);
		pr[i] /= 100;
	}
	for (i = 2; i <= n; ++i)
		a[i] = .5 * v[i] - pr[i] * c;

	build (1, 2, n);
	double ans = .0;
	for (; m; --m) {
		int ai, bi;
		scanf ("%d%d", &ai, &bi);
		qtype ret = query (1, ai + 1, bi);
		ans += ret.ma;
	}

/*
	d[1] = .0; double ans = .0;
	for (i = 2; i <= n; ++i) {
		d[i] = d[i-1] > 1e-15 ? d[i-1] + a[i] : a[i];
		ans = max (ans, d[i]);
	}
	for (i = 2; i <= n; ++i)
		printf ("%d%c", v[i], i == n ? '\n' : ' ');

	for (i = 2; i <= n; ++i)
		printf ("%.3lf%c", a[i], i == n ? '\n' : ' ');

	for (i = 2; i <= n; ++i)
		printf ("%.3lf%c", d[i], i == n ? '\n' : ' ');*/

	printf ("%.15lf\n", ans);
	return 0;
}

/*
5 5 651
0 438 1449 2349 3194
67 6 98 38
3 5
1 3
4 5
1 3
2 3
1749.56
 */