fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. ll c[1000003],k,x,ma;
  5. int main()
  6. {
  7. ll n,i;
  8. cin>>n;
  9. for(i=1;i<=n;i++)
  10. {
  11. cin>>x;
  12. k=sqrt(x);
  13. ma=max(ma,k);
  14. if(k*k==x) c[k]=1;
  15. }
  16. for(i=0;i<=ma+1;i++)
  17. if(c[i]==0)
  18. {
  19. cout<<i*i;
  20. break;
  21. }
  22. }
  23.  
Success #stdin #stdout 0.01s 5280KB
stdin
8
0 3 4 2 1 4 16 25
stdout
9