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