def solve(string):
    n, m, *a = map(int, string.split())
    for i in range(1, n):
        a[i] += a[i - 1]
    a=[0]+a
    ans = 0
    for i in range(1,n+1):
        for j in range(i):
            if (a[i]-a[j])%m==0:
                ans+=1
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
