#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    int A;
    int cumulative_sum[N + 1] = {};
    for (int i = 1; i <= N; i++)
    {
        cin >> A;
        cumulative_sum[i] = (cumulative_sum[i - 1] + A) % M;
    }

    long long ans = 0;
    for (int i = 1; i <= N; i++)
    {
        for (int j = i; j <= N; j++)
        {
            if ((cumulative_sum[j] - cumulative_sum[i - 1]) % M == 0)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}
