#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  for (long long(i) = (0); (i) < (N); ++i) {
    cin >> a[i];
    a[i] %= M;
  }
  vector<int> sum(N + 1);
  sum[0] = 0;
  for (long long(i) = (0); (i) < (N); ++i) sum[i + 1] = (sum[i] + a[i]) % M;
  map<int, int> mp;
  for (long long(i) = (0); (i) < (N + 1); ++i) mp[sum[i]]++;
  long long ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    ans += itr->second * (itr->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
