#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];

    // L R
    long long dp[N][N] = {};
    long long r = 0;
    for (long long i = 0; i < N; i++) for (long long j = i; j < N; j++) {
            long long c = (j == i ? 0 : dp[i][j - 1]) + A[j];
            dp[i][j] = c;
            if (c % M == 0) r++;
    }
    
    cout << r << endl;
}