#include <bits/stdc++.h>
using namespace std;
int main() {
  multiset<int> s;
  int N, M, x, sum = 0;
  long long ans = 0;
  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    cin >> x;
    sum += x;
    sum = sum % M;
    s.insert(sum);
  }
  while (!s.empty()) {
    auto itr = s.begin();
    int a = s.count(*itr);
    if (*itr == 0) {
      ans += a + a * (a - 1) / 2;
    } else
      ans += a * (a - 1) / 2;
    s.erase(*itr);
  }
  cout << ans << endl;
}
