#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> b(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    b[i] = (b[i - 1] + a[i]) % m;
  }
  sort(b.begin(), b.end());
  long long ans = 0;
  long long c = 1;
  for (int i = 1; i <= n; i++) {
    if (b[i] == b[i - 1]) {
      c++;
    } else {
      ans += c * (c - 1) / 2;
      c = 1;
    }
  }
  ans += c * (c - 1) / 2;
  cout << ans << endl;
  return 0;
}
