#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  map<int, vector<int>> key;
  int buf = 0;
  for (int i = 0; i < n; i++) {
    buf += a[i];
    buf = buf % m;
    key.at(buf).push_back(i);
  }
  int ans = 0;
  buf = 0;
  for (int i = 0; i < n; i++) {
    while (key.count(buf))
      if (key[buf][0] < i)
        key[buf].erase(key[buf].begin());
      else
        break;
    ans += key.at(buf).size();
    buf += a[i];
    buf = buf % m;
  }
  cout << ans << endl;
  return 0;
}
