#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
int main() {
  int n, m;
  vector<int> a(n);
  long long ans = 0;
  cin >> n >> m;
  for (int(i) = 0; (i) < (int)(n); ++(i)) {
    cin >> a[i];
    a[i] %= m;
  }
  int wa = 0;
  for (int(i) = 0; (i) < (int)(n); ++(i)) {
    wa += a[i];
    wa %= m;
    a[i] = wa;
  }
  mp[0] = 1;
  for (int(i) = 0; (i) < (int)(n); ++(i)) {
    ans += mp[a[i]];
    mp[a[i]]++;
  }
  cout << ans << endl;
  return 0;
}
