Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_sort(a, n):
- for i in range(n-1):
- if a[i] > a[i+1]:
- return False
- return True
- if __name__ == '__main__':
- n = int(input())
- a = [int(i) for i in input().split()]
- if is_sort(a, n):
- print(max(a) - min(a))
- else:
- print(-1)
Advertisement
Add Comment
Please, Sign In to add comment