Height of Towers


An array of integers given denoting the height of the tower, positive integer X is also given. You have to modify the height of towers by increasing or decreasing them by X only once.

After modifying, find out, what could be the possible minimum difference of the height between the shortest and the longest towers.

Write a function solve that have the following parameter(s):
1.) arr = an array of integer denoting the height of towers
2.) a = integer

Example
Input:
arr = [4,6,9]
X = 3
Output:
5

Explanation
An array can be modified as {7, 9, 12}.
The difference between the largest and the smallest is 6-1 = 5.

Constraints
• The value of X will be greater than or equal to 1 and less than or equal to 1000.
• Number of elements in the array will be greater than or equal to 1 and less than or equal to 10000.
• Each element in the array will be greater than or equal to 1 and less than or equal to 10000.