@staticmethod
def b():
    (n, *a) = map(int, sys.stdin.read().split())
    (m, r) = divmod(sum(a), n)
    if r:
        print((- 1))
        return
    population = 0
    towns = 0
    cnt = 0
    for x in a:
        population += x
        towns += 1
        if ((population / towns) != m):
            cnt += 1
            continue
        (population, towns) = (0, 0)
    print(cnt)
@staticmethod
def b():
    (n, *a) = map(int, sys.stdin.read().split())
    (m, r) = divmod(sum(a), n)
    if r:
        print((- 1))
        return
    population = 0
    towns = 0
    cnt = 0
    for x in a:
        population += x
        towns += 1
        if ((population / towns) != m):
            cnt += 1
            continue
        (population, towns) = (0, 0)
    print(cnt)