#include <bits/stdc++.h>
using namespace std;
long long candy_distribution(int n, long long m, std::vector<long long> a) {
  map<long long, int> mp;
  long long sum;
  for (int i = 0; i < a.size(); i++) {
    if (i == 0) {
      sum = a[0];
    } else {
      sum += a[i];
    }
    int k = sum % m;
    auto found = mp.find(k);
    if (found == mp.end()) {
      mp.insert(make_pair(k, 1));
    } else {
      mp[k] = mp.at(k) + 1;
    }
  }
  long long ans = 0;
  for (auto i = mp.begin(); i != mp.end(); ++i) {
    int size = i->second;
    ans += (size * (size - 1)) / 2;
    if (i->first == 0) ans += i->second;
  }
  return ans;
}
int main() {
  int n;
  long long m;
  cin >> n >> m;
  vector<long long> a;
  for (int i = 0; i < n; i++) {
    long long a_i;
    cin >> a_i;
    a.push_back(a_i);
  }
  cout << candy_distribution(n, m, a);
}
