counting the number of inversions

This Question Was Asked By Google

We can determine how "out of order" an array A is by counting the number of inversions it has. Two elements A[i] and A[j] form an inversion if A[i] > A[j] but i < j. That is, a smaller element appears after the larger element.

Write a function solve that have the following parameter(s):
1.) a = an array of integers

Example
Input:
[2, 4, 1, 3, 5]
Output:
3

Example
Input:
[1, 2, 3, 4, 5]
Output:
0

Constraints
• The length of an array should be greater than 0 and less than 800.
• The elements of an array should be greater than 0 and less than 1000.