Ankit_132

B

Aug 27th, 2023
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll     long long
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7. #define ff     first
  8. #define pb     push_back
  9.  
  10. int main()
  11. {
  12.     int n;
  13.     cin>>n;
  14.  
  15.     vector<int> a(n);
  16.     for(auto &e: a)
  17.       cin>>e;
  18.  
  19.     sort(a.begin(), a.end());
  20.  
  21.     for(int i=1; ;i++)
  22.     {
  23.         if(a[i]-1 != a[i-1])
  24.         {
  25.             cout<<a[i]-1<<"\n";
  26.             break;
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment