kasougi

Untitled

Jun 5th, 2021
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. def is_sort(a, n):
  2. for i in range(n-1):
  3. if a[i] > a[i+1]:
  4. return False
  5. return True
  6.  
  7.  
  8. if __name__ == '__main__':
  9. n = int(input())
  10. a = [int(i) for i in input().split()]
  11. if is_sort(a, n):
  12. print(max(a) - min(a))
  13. else:
  14. print(-1)
Advertisement
Add Comment
Please, Sign In to add comment