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

int main() {
    long long N, M;
    cin >> N >> M;
    long long A[N];
    for (long long i = 0; i < N; i++) cin >> A[i];

    long long a = 0;
    for (long long l = 0; l < N; l++) {
        long long dp[N] = {};
        for (long long r = l; r < N; r++) {
            long long c = (r == 0 ? 0 : dp[r - 1]) + A[r];
            dp[r] = c;
            if (c % M == 0) a++;
        }
    }
    
    cout << a << endl;
}