a = [1, 2, 4, 4, 2, 2, 1, 4]
length = len(a)
i = 0
max = a[i]
while (i < length):
if(a[i] > max):
max = a[i]
i += 1
counter = 0
i = 0
result = length
while (i < length):
if(max == a[i]):
counter = counter + 1
if(i == (length - 1) or a[i+1] != max):
if(counter < result):
result = counter
counter = 0
i += 1
print(result)
input()