#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N, M;
  cin >> N >> M;
  long long i;
  long long a[101010];
  long long s[101010];
  map<long long, long long> mp;
  s[0] = 0;
  mp[s[0]]++;
  for (i = 0; i < N; i++) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
    mp[s[i + 1] % M];
  }
  long long ans = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    long long t = it->second;
    ans += t * (t - 1) / 2;
  }
  cout << ans << "\n";
}
