#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, M;
  cin >> N >> M;
  unordered_map<int64_t, int64_t> count;
  int64_t sum = 0;
  int64_t answer = 0;
  for (int i = 0; i < (N); ++i) {
    int a;
    cin >> a;
    sum = (sum + a) % M;
    count[sum]++;
    if (a % M == 0 || sum == 0) ++answer;
  }
  for (auto& n : count) {
    int64_t pair = (M - n.first) % M;
    if (n.second == 0) continue;
    if (pair == n.first) {
      answer += (n.second) * (n.second - 1) / 2;
    } else if (count.count(pair)) {
      answer += n.second * count[pair];
      count[pair] = 0;
    }
  }
  cout << answer << endl;
  return 0;
}
