#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main() {
  int n;
  long long m;
  cin >> n >> m;
  long long a[n];
  long long b[n + 1];
  map<long long, int> mp;
  b[0] = 0;
  mp[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i + 1] = (b[i] + a[i]) % m;
    auto itr = mp.find(b[i + 1]);
    if (itr != mp.end()) {
      mp[b[i + 1]]++;
    } else {
      mp[b[i + 1]] = 1;
    }
  }
  long long ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    ans += itr->second * (itr->second - 1) / 2;
  }
  cout << ans << endl;
}
