#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  long long b[100001], c = 0;
  unordered_map<int, int> p{};
  cin >> n >> m;
  b[0] = 0;
  p[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    b[i] += b[i - 1];
    b[i] %= m;
    p[b[i]] = p[b[i]];
    p[b[i]]++;
  }
  for (const auto& [x, y] : p) {
    c += y * (y - 1) / 2;
  }
  cout << c << endl;
  return 0;
}
