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