#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long M;
  cin >> N >> M;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  long S = 0;
  vector<bool> Done(N, false);
  for (int i0 = 0; i0 < N; i0++) {
    if (Done.at(i0)) continue;
    long SS = 0;
    int i1 = i0;
    while (i1 < N) {
      SS += A.at(i1);
      if (0 == SS % M) break;
      i1++;
    }
    if (i1 != N) {
      long SSS = 2;
      if (N > i1 + 1) Done.at(i1 + 1) = true;
      i1++;
      for (; i1 < N; i1++) {
        SS += A.at(i1);
        if (0 == SS % M) {
          SSS++;
          if (N > i1 + 1) Done.at(i1 + 1) = true;
        }
      }
      S += SSS * (SSS - 1) / 2;
    }
  }
  cout << S << endl;
  return 0;
}
