#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long niza[n];
  long long zbirovi[n];
  map<long long, vector<long long>> mapa;
  for (long long i = 0; i < n; i++) {
    cin >> niza[i];
    if (i != 0)
      zbirovi[i] = zbirovi[i - 1] + niza[i];
    else
      zbirovi[i] = niza[i];
  }
  for (long long i = 0; i < n; i++) {
    zbirovi[i] %= m;
    mapa[zbirovi[i]].push_back(i);
  }
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    long long br = zbirovi[i];
    if (br % m == 0) res++;
    long long brBaram = m - br;
    if (brBaram == m) brBaram = 0;
    res +=
        long long(lower_bound(mapa[brBaram].begin(), mapa[brBaram].end(), i) -
                  mapa[brBaram].begin());
  }
  cout << res << endl;
  return 0;
}
