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