fork download
  1. # your code goes here
  2. import sys
  3. input = sys.stdin.readline
  4.  
  5. roof = int(input().rstrip())
  6. line = list(map(int, input().rstrip().split()))
  7.  
  8. order = min(line)
  9. stack = []
  10.  
  11. for _ in line:
  12. if order == _:
  13. line.remove(order)
  14. order = min(line)
  15. pass
  16. elif order != _:
  17. stack.append(_)
  18.  
  19. stack_validation = sorted(stack, reverse = True)
  20.  
  21. if stack_validation == stack:
  22. print("Nice")
  23. else:
  24. print("Sad")
Success #stdin #stdout 0.02s 7128KB
stdin
5
5 3 1 2 4
stdout
Sad