Question: I'm drawing groups of five lines, but the fifth of each group always appears blurred. This is the result:
[![enter image description here](https://i.stack.imgur.com/VEuAv.png)](https://i.stack.imgur.com/VEuAv.png)

And this is my JavaScript code:

```
for (i=0; i<5; i++){
    context.moveTo(X, Y);
    context.lineTo(X + length, Y);
    context.stroke();
    Y += space; 
}

```

Answer: 
**Edit 1:**
To relate to this solution better, it is good to mention what user *Dukeling* has said in his comments. That is, increasing all other elements except the largest element is similar to decreasing only the largest element.

---

Now, imagine you are trying to level many columns of bricks. Each column of bricks can be of different level:

In order to level all column of bricks, you always pick the highest column and remove 1 brick at a time.

Repeat the process till all columns are levelled.
[![enter image description here](https://i.stack.imgur.com/0tGvO.png)](https://i.stack.imgur.com/0tGvO.png)

Those coloured in yellow are the bricks you need to remove to achieve your goal.(they also mean the number of operations you need to perform to reach your goal) 

In order to count number of red bricks, you use a simple formula similar to area of rectangle, that is length x breadth.

```
min x number of columns = all the red bricks (to be remained untouched)

sum of all bricks - number of red bricks = all yellow bricks 

```

Hence you have the formula:

```
minOperation = sum - (n * small) 

```

[![enter image description here](https://i.stack.imgur.com/QaF4U.png)](https://i.stack.imgur.com/QaF4U.png)

Number of yellows = minimum number of operations needed to make all array elements equal.
use a simple formula:

Sum of array element - (size of the array \* minimum element from the array)

Example
array = {1, 2, 3, 4, 5} n = 5 // size of array

sum = 15, min = 1

ans = sum - (min \* n) = 10

[uniformarray](/questions/tagged/uniformarray "show questions tagged 'uniformarray'") [array](/questions/tagged/array "show questions tagged 'array'") [bricksproblem](/questions/tagged/bricksproblem "show questions tagged 'bricksproblem'")