fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define Khashwaa() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  4. #define ulld unsigned long long
  5. #define itn int
  6. #define endl '\n'
  7. #define lld long long
  8. #define fix(n) fixed << setprecision(n)
  9. #define gcd(x,y) __gcd(x, y)
  10. #define lcm(x,y) (x/(__gcd(x,y))*y)
  11. #define all(v) v.begin(),v.end()
  12. #define rall(v) v.rbegin(),v.rend()
  13. #define Uint unsigned int
  14. #define tostr(n,s) ostringstream St;St<<n;string s=St.str();
  15. void mini(lld &a, lld b) { a = std::min(a, b); }
  16. void maxi(lld &a, lld b) { a = std::max(a, b); }
  17. int dx[] = { 1, 0, -1, 0 };
  18. int dy[] = { 0, -1, 0, 1 };
  19.  
  20. const lld N = 1e6 + 7;
  21. const lld MOD = 1e9 + 7;
  22.  
  23. using namespace std;
  24.  
  25. void _Function()
  26. {
  27. int n;cin >> n;
  28. vector<int> a(n);
  29. for (int i = 0;i < n; ++i) cin >> a[i];
  30. int x = -1;
  31. for (int i = 0;i < n; ++i){
  32. if(a[i] != i){
  33. x = max(x , a[i] & i);
  34. }
  35. }
  36. cout << x << endl;
  37. }
  38. int32_t main()
  39. {
  40. Khashwaa();
  41. int t = 1;cin >> t;
  42. while(t--){
  43. _Function();
  44. }
  45. }
  46.  
Success #stdin #stdout 0.01s 5300KB
stdin
Standard input is empty
stdout
-1