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