#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000000;
long long mod = 1000000007;
int main() {
  long long N, M;
  cin >> N >> M;
  long long A[N];
  long long s[N + 1];
  s[0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    s[i + 1] = s[i] + A[i];
  }
  map<long long, int> mp;
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    long long res = s[i] % M;
    if (mp.find(res) == mp.end())
      mp.insert(make_pair(res, 1));
    else {
      mp[res]++;
    }
    if (res == 0) ans++;
  }
  auto it = mp.begin();
  while (it != mp.end()) {
    int n = it->second;
    ans += n * (n - 1) / 2;
    it++;
  }
  cout << ans << endl;
  return 0;
}
