Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int g,t,y,bm,re;
- scanf("%d",&t);
- while(t--){
- scanf("%d",&y);
- int wq[y+3];
- for(g=0;g<y;g++)scanf("%d",&wq[g]);
- sort(wq,wq+y);
- bm=min(wq[y-2],wq[y-1]);
- re=min(bm-1,y-2);
- printf("%d\n",re);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement