#include <bits/stdc++.h>
using namespace std;
void solve4() {
  int N, M, A;
  cin >> N >> M;
  int sum = 0;
  map<long long, int> mp;
  mp[0] = 1;
  for (int i = 0; i < N; ++i) {
    cin >> A;
    sum += A;
    sum %= M;
    mp[sum]++;
  }
  long long ans = 0;
  for (const auto& p : mp) {
    int count = p.second;
    if (count != 1) {
      ans += count * (count - 1) / 2;
    }
  }
  cout << ans << '\n';
}
int main() {
  solve4();
  return 0;
}
