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