You are given array $a_1, a_2, \dots, a_n$. Find the subsegment $a_l, a_{l+1}, \dots, a_r$ ($1 \le l \le r \le n$) with maximum arithmetic mean $\frac{1}{r - l + 1}\sum\limits_{i=l}^{r}{a_i}$ (in floating-point numbers, i.e. without any rounding).

If there are many such subsegments find the longest one.


-----Input-----

The first line contains single integer $n$ ($1 \le n \le 10^5$) — length of the array $a$.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 10^9$) — the array $a$.


-----Output-----

Print the single integer — the length of the longest subsegment with maximum possible arithmetic mean.


-----Example-----
Input
5
6 1 6 6 0

Output
2



-----Note-----

The subsegment $[3, 4]$ is the longest among all subsegments with maximum arithmetic mean.

Difficulty: interview

Starter code:

Solutions:
n = int(input())
a = list(map(int,input().split()))
m = max(a)

current = 0
longest = 0
for x in a:
    if x == m:
        current +=1
    else:
        longest = max(current,longest)
        current = 0
longest = max(current,longest)
print (longest)



ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())

n = ii()
a = li()
m = max(a)
i = 0
ans = 1
while i < n:
    j = i + 1
    while j < n and a[i] == a[j]:
        j += 1
    if a[i] == m:
        ans = max(ans, j - i)
    i = j
print(ans)

n = int(input())
a = list(map(int, input().split()))
q = max(a)
tmp = 0
num = 0
for i in range(n):
    if a[i] == q:
        tmp += 1
    else:
        num = max(num, tmp)
        tmp = 0
num = max(num, tmp)
print(num)


n = int(input())
A = list(map(int, input().split()))
z = max(A)
cnt = 0
hop = 0
for i in A:
    hop = max(hop, cnt)
    if i == z:
        cnt += 1
    else:
        cnt = 0
hop = max(hop, cnt)
print(hop)

#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

isdebug = False
try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
    isdebug = True
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if not isdebug:
    inId = 0
    outId = 0
if inId>0:
    dprint('use input', inId)
    try:
        f = open('input'+ str(inId) + '.txt', 'r')
        sys.stdin = f #标准输出重定向至文件
    except Exception:
        dprint('invalid input file')
if outId>0:
    dprint('use output', outId)
    try:
        f = open('stdout'+ str(outId) + '.txt', 'w')
        sys.stdout = f #标准输出重定向至文件
    except Exception:
        dprint('invalid output file')
        
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N, = getIntList()
#print(N)
za  = getIntList()
t = max(za)
l = 0
r = 0
for x in za:
    if x==t:
        l+=1
    else:
        l=0
    r = max(r,l)
print(r)






n=int(input())
a=list(map(int,input().split()))
k=max(a)

p=0
ans = 1
for i in range(n):
	if a[i]==k:
		p+=1
	else:
		ans = max(ans,p)
		p=0
ans = max(ans,p)
print(ans)


n = int(input())
A = list(map(int, input().split()))
a = max(A)
acc = 0
ans = 1
for b in A:
  if b == a:
    acc += 1
  else:
    acc = 0
  ans = max(ans, acc)
print(ans)


n = int(input())
a = list(map(int, input().split()))
c = max(a)
le = 0
ans = -1
for i in range(n):
    if c == a[i]:
        le += 1
    else:
        le = 0
    ans = max(ans, le)
print(ans)

n = int(input())
s = list(map(int, input().split()))
m = -1
row = 0
mr = 0
for i in s:
    if i == m:
        row += 1
    elif(i > m):
        m = i
        row = 1
        mr = 0
    else:
        row = 0
    mr = max(mr, row)
print(mr)

n=int(input())
arr=list(map(int,input().split()))
max1=max(arr)
i=0
ans=1
while(i<n):
	if(arr[i]==max1):
		count=0
		while(i<n and arr[i]==max1):
			count+=1
			i+=1
		ans=max(ans,count)
	i+=1
print(ans)

def mi():
    return list(map(int, input().split()))
'''
5
6 1 6 6 0
'''
n = int(input())
a = list(mi())
t = max(a)

cnt = 0
i = 0
while i<n:
    if a[i]==t:
        curcnt = 0
        while i<n and a[i]==t:
            curcnt+=1
            i+=1
        cnt = max(cnt, curcnt)
    i+=1
print (cnt)


n = int(input())
arr = list(map(int, input().split()))
m = max(arr)
c = 0
temp = 0
for x in arr:
    if x == m:
        c += 1
    else:
        if temp < c: temp = c
        c = 0
if temp < c: temp = c
print(temp)


N = int(input())
A = [int(a) for a in input().split()]

m = max(A)
ma = 0
c = 0
for i in range(N):
    if A[i] == m:
        c += 1
        ma = max(ma, c)
    else:
        c = 0
print(ma)

''' CODED WITH LOVE BY SATYAM KUMAR '''


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left,bisect,bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
sys.setrecursionlimit(10**6) # max depth of recursion
threading.stack_size(2**27)  # new thread will get stack of such size
fac_warmup = False
printHeap = str()
memory_constrained = False
P = 10**9+7
import sys

class Operation:
    def __init__(self, name, function, function_on_equal, neutral_value=0):
        self.name = name
        self.f = function
        self.f_on_equal = function_on_equal
def add_multiple(x, count):
    return x * count
def min_multiple(x, count):
    return x
def max_multiple(x, count):
    return x
sum_operation = Operation("sum", sum, add_multiple, 0)
min_operation = Operation("min", min, min_multiple, 1e9)
max_operation = Operation("max", max, max_multiple, -1e9)
class SegmentTree:
    def __init__(self,
                 array,
                 operations=[sum_operation, min_operation, max_operation]):
        self.array = array
        if type(operations) != list:
            raise TypeError("operations must be a list")
        self.operations = {}
        for op in operations:
            self.operations[op.name] = op
        self.root = SegmentTreeNode(0, len(array) - 1, self)
    def query(self, start, end, operation_name):
        if self.operations.get(operation_name) == None:
            raise Exception("This operation is not available")
        return self.root._query(start, end, self.operations[operation_name])
    def summary(self):
        return self.root.values
    def update(self, position, value):
        self.root._update(position, value)
    def update_range(self, start, end, value):
        self.root._update_range(start, end, value)
    def __repr__(self):
        return self.root.__repr__()
class SegmentTreeNode:
    def __init__(self, start, end, segment_tree):
        self.range = (start, end)
        self.parent_tree = segment_tree
        self.range_value = None
        self.values = {}
        self.left = None
        self.right = None
        if start == end:
            self._sync()
            return
        self.left = SegmentTreeNode(start, start + (end - start) // 2,
                                    segment_tree)
        self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end,
                                     segment_tree)
        self._sync()
    def _query(self, start, end, operation):
        if end < self.range[0] or start > self.range[1]:
            return None
        if start <= self.range[0] and self.range[1] <= end:
            return self.values[operation.name]
        self._push()
        left_res = self.left._query(start, end,
                                    operation) if self.left else None
        right_res = self.right._query(start, end,
                                      operation) if self.right else None
        if left_res is None:
            return right_res
        if right_res is None:
            return left_res
        return operation.f([left_res, right_res])
    def _update(self, position, value):
        if position < self.range[0] or position > self.range[1]:
            return
        if position == self.range[0] and self.range[1] == position:
            self.parent_tree.array[position] = value
            self._sync()
            return
        self._push()
        self.left._update(position, value)
        self.right._update(position, value)
        self._sync()
    def _update_range(self, start, end, value):
        if end < self.range[0] or start > self.range[1]:
            return
        if start <= self.range[0] and self.range[1] <= end:
            self.range_value = value
            self._sync()
            return
        self._push()
        self.left._update_range(start, end, value)
        self.right._update_range(start, end, value)
        self._sync()
    def _sync(self):
        if self.range[0] == self.range[1]:
            for op in self.parent_tree.operations.values():
                current_value = self.parent_tree.array[self.range[0]]
                if self.range_value is not None:
                    current_value = self.range_value
                self.values[op.name] = op.f([current_value])
        else:
            for op in self.parent_tree.operations.values():
                result = op.f(
                    [self.left.values[op.name], self.right.values[op.name]])
                if self.range_value is not None:
                    bound_length = self.range[1] - self.range[0] + 1
                    result = op.f_on_equal(self.range_value, bound_length)
                self.values[op.name] = result
    def _push(self):
        if self.range_value is None:
            return
        if self.left:
            self.left.range_value = self.range_value
            self.right.range_value = self.range_value
            self.left._sync()
            self.right._sync()
            self.range_value = None
    def __repr__(self):
        ans = "({}, {}): {}\n".format(self.range[0], self.range[1],
                                      self.values)
        if self.left:
            ans += self.left.__repr__()
        if self.right:
            ans += self.right.__repr__()
        return ans

def display(string_to_print):
    stdout.write(str(string_to_print) + "\n")

def primeFactors(n): #n**0.5 complex 
    factors = dict()
    for i in range(2,math.ceil(math.sqrt(n))+1):  
        while n % i== 0: 
            if i in factors:
                factors[i]+=1
            else: factors[i]=1
            n = n // i 
    if n>2:
        factors[n]=1
    return (factors)

def binary(n,digits = 20):
    b = bin(n)[2:]
    b = '0'*(20-len(b))+b
    return b

def isprime(n):
    """Returns True if n is prime."""
    if n < 4:
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    i = 5
    w = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += w
        w = 6 - w
    return True
factorial_modP = []
def warm_up_fac(MOD):
    nonlocal factorial_modP,fac_warmup
    if fac_warmup: return
    factorial_modP= [1 for _ in range(fac_warmup_size+1)]
    for i in range(2,fac_warmup_size):
        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD
    fac_warmup = True

def InverseEuler(n,MOD):
    return pow(n,MOD-2,MOD)

def nCr(n, r, MOD):
    nonlocal fac_warmup,factorial_modP
    if not fac_warmup:
        warm_up_fac(MOD)
        fac_warmup = True
    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD

def test_print(*args):
    if testingMode:
        print(args)

def display_list(list1, sep=" "):
    stdout.write(sep.join(map(str, list1)) + "\n")

def get_int():
    return int(stdin.readline().strip())

def get_tuple():
    return map(int, stdin.readline().split())

def get_list():
    return list(map(int, stdin.readline().split()))
import heapq,itertools
pq = []                         # list of entries arranged in a heap
entry_finder = {}               # mapping of tasks to entries
REMOVED = '<removed-task>' 
def add_task(task, priority=0):
    'Add a new task or update the priority of an existing task'
    if task in entry_finder:
        remove_task(task)
    count = next(counter)
    entry = [priority, count, task]
    entry_finder[task] = entry
    heapq.heappush(pq, entry)

def remove_task(task):
    'Mark an existing task as REMOVED.  Raise KeyError if not found.'
    entry = entry_finder.pop(task)
    entry[-1] = REMOVED

def pop_task():
    'Remove and return the lowest priority task. Raise KeyError if empty.'
    while pq:
        priority, count, task = heapq.heappop(pq)
        if task is not REMOVED:
            del entry_finder[task]
            return task
    raise KeyError('pop from an empty priority queue')
memory = dict()
def clear_cache():
    nonlocal memory
    memory = dict()
def cached_fn(fn, *args):
    nonlocal memory
    if args in memory:
        return memory[args]
    else:
        result = fn(*args)
        memory[args] = result
        return result


# -------------------------------------------------------------- MAIN PROGRAM
TestCases = False
testingMode = False
fac_warmup_size = 10**5+100
optimiseForReccursion = True #Can not be used clubbed with TestCases

def main():
    n = get_int()
    li = get_list()
    maxi = max(li)
    c=0
    res = 1
    for i in li:
        if i==maxi:
            c+=1
        else:
            res=max(c,res)
            c=0
    res=max(c,res)
    print(res)

# --------------------------------------------------------------------- END=


if TestCases: 
    for _ in range(get_int()): 
        cProfile.run('main()') if testingMode else main() 
else: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()

n=int(input())
A=list(map(int,input().split()))

M=max(A)
ANS=0
count=0
for a in A:
    if a==M:
        count+=1
        if ANS<count:
            ANS=count
    else:
        count=0
print(ANS)


n = int(input())
A = [int(x) for x in input().split()]
mx = max(A)

streak = 0
cur = 0
for a in A:
    if a == mx:
        cur += 1
        streak = max(streak, cur)
    else:
        cur = 0
print(streak)


#	!/usr/bin/env python3
#	coding: UTF-8
#	Modified: <18/Feb/2019 09:13:07 PM>


#	✪ H4WK3yE乡
#	Mohd. Farhan Tahir
#	Indian Institute Of Information Technology (IIIT),Gwalior

#	Question Link
#
#

# ///==========Libraries, Constants and Functions=============///


import sys

inf = float("inf")
mod = 1000000007


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return list(map(int, sys.stdin.readline().split()))


def input(): return sys.stdin.readline()

# ///==========MAIN=============///


def main():
    n = int(input())
    arr = get_array()
    #from collections import Counter
    maxi = max(arr)
    mx, curr = 0, 0
    for i in range(n):
        if arr[i] == maxi:
            curr += 1
            mx = max(mx, curr)
        else:
            curr = 0
    print(mx)


def __starting_point():
    main()

__starting_point()

def inpl(): return list(map(int, input().split()))

N = int(input())
A = inpl() + [-1]

x = max(A)
ctr = 0
ans = 0
for a in A:
    if a == x:
        ctr += 1
    else:
        ans = max(ans, ctr)
        ctr = 0
print(ans)

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    n = int(input())
    A = list(map(int, input().split()))
    m = max(A)

    res = 0
    c = 0
    for a in A:
        if (a==m):
            c += 1
            res = max(res, c)
        else:
            c = 0
    print(res)
    return 0

def __starting_point():# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}

__starting_point()

n = int(input())

a = list(map(int, input().split()))

mx = max(a)

c = 0
mc = 0

for i in range(n):
    if a[i] == mx:
        c += 1
        mc = max(mc, c)
    else:
        mc = max(mc, c)
        c = 0
print(mc)

n=int(input())
a=[int(s) for s in input().split()]
a.append(-1)
mx=max(a)
ans=1
k=0
for i in range(n+1):
    if a[i]==mx:
        k+=1
    else:
        ans=max(ans,k)
        k=0
print(ans)
    


n=int(input())
a=list(map(int,input().split()))
mx=max(a)
cnt=0
ans=0
for i in range(n):
    if a[i]==mx:
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
ans=max(ans,cnt)
print(ans)



n = int(input())
arr = [int(x) for x in input().split()]
max_val = max(arr)

max_len = 0
cur_len = 0
for a in arr:
    if a == max_val:
        cur_len += 1
        max_len = max(cur_len, max_len)
    else:
        cur_len = 0

print(max_len)


amount = int(input())
array = [int(s) for s in input().split()]
max_ = max(array)
counter = 0
counter_max = 0
for i in range(len(array)):
    if array[i] == max_:
        counter += 1
        if counter > counter_max:
            counter_max = counter
    else:
        counter = 0
print(counter_max)