Question unable to solve it?

A global shipping company wants to identify the reason behind their losses. For it they formed an auditing team and found that the losses were due to various tax rates on different items. The auditing team then made a list of tax rates of N items, Each item in the list has been identified by a unique ID ranging from 0 to (N-1). The auditing team then put this list into their system and formed a policy to achieve a common tax rate on all items. To reach to the common tax rate the company will increase the tax rate of every item by 1 every month. At the same time the company will focus on a particular item each month and the tax rate of that particular item will not be increased in that month. The system will repeat this process until all the tax rates are the same. Write an algorithm for the system to tell the minimum number of months required to make all the tax rates same.

Input:

The first line of the input consists of an integer - totalitems, representing the total items in the list
(N)
The second line consists of N space-separated integer - tax tax. …, tax-q, representing the different tax rates.
Output:

Print an integer representing the minimum number of months required to make all the tax rates