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: 
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'")
i have solve this question using binary search!

```
def main():
#codechef question SALARY 
t = input()
t = int(t)
while t > 0:
    n = input()
    n = int(n)
    val = list(map(int, input().split(" ")))
    initial_sum = sum(val)
    min_value = min(val)
    left = 0
    right = 10000000000
    while left <= right:
        mid = (left + right) // 2
        may_be = initial_sum + (mid * (n-1))
        mean = may_be / n
        diff = mean - min_value
        if diff == mid:
            break
        elif diff < mid:
            right = mid - 1
        else:
            left = mid + 1
    print(mid)
    t -= 1

```

if **name** == '**main**':
 main()