First we sort the array `A`

. After sorting, if `A[0] >= 0 or A[-1] <= 0`

, we know the answer is `A[-3]*A[-2]*A[-1]`

. Otherwise, when `A[0] < 0 < A[-1]`

, we consider two sub-situations `A[0]*A[1]*A[-1]`

and `A[0]*A[1]*A[2]`

which depends on whether `A[-1]`

is positive or not.

```
class Solution(object):
def maximumProduct(self, A):
"""
:type A: List[int]
:rtype: int
"""
A.sort()
return max(A[-3]*A[-2]*A[-1], A[0]*A[1]*A[-1])
```