kinoooshnik

Untitled

Dec 5th, 2020
710
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def main():
  2.     with open("input.txt", "r") as file:
  3.         n = int(file.readline())
  4.         ks = [int(i) for i in file.readline().split()]
  5.  
  6.     ks = sorted(ks, reverse=True)
  7.  
  8.     c = 0
  9.     for k in ks:
  10.         if c == k:
  11.             return -1
  12.         elif c + 1 > k:
  13.             return c
  14.         else:
  15.             c += 1
  16.     return c
  17.  
  18.  
  19. if __name__ == '__main__':
  20.     print(main())
  21.  
RAW Paste Data