#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[buf].push_back(i);
  }
  int ans = 0;
  buf = 0;
  for (int i = 0; i < n; i++) {
    while (key.at(buf).size() && key.at(buf).at(0) < i) {
      key[buf].erase(key[buf].begin());
    }
    ans += key.at(buf).size();
    buf += a[i];
    buf = buf % m;
  }
  cout << ans << endl;
  return 0;
}
