---
# System prepended metadata

title: 5881. Maximum Difference Between Increasing Elements

---

# 5881. Maximum Difference Between Increasing Elements
```
class Solution:
    def maximumDifference(self, nums: List[int]) -> int:
        result = []
        for i in range(len(nums)):
            for j in range(i, len(nums)):
                if nums[j] > nums[i]:
                    result.append(nums[j] - nums[i])
                else:
                    result.append(-1)
        if max(result) < 0:
            return -1
        else:
            return max(result)
```