#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, tmp, sum = 0, ans = 0;
  map<long long, long long> mp;
  long long count = 0;
  cin >> N >> M;
  mp[0] = 1;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    sum = (sum + tmp) % M;
    if (mp.find(sum) != mp.end()) {
      ans += mp[sum];
      mp[sum]++;
    } else {
      mp[sum] = 1;
    }
  }
  cout << ans << "\n";
  return 0;
}
