#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, sum, a[100010], s[100010], mod[100010];
  map<long long, long long> mp;
  vector<long long> v;
  cin >> n >> m;
  sum = 0;
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
    sum += a[i];
    s[i] = sum;
    mod[i] = sum % m;
    if (mp[mod[i]] == 0) {
      v.push_back(mod[i]);
    }
    mp[mod[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] % m == 0) ans += mp[v[i]];
    ans += mp[v[i]] * (mp[v[i]] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
