#include <bits/stdc++.h>
using namespace std;
using p = pair<long long, long long>;
long long dx[4] = {-1, 0, 1, 0};
long long dy[4] = {0, 1, 0, -1};
int main() {
  long long n, m;
  cin >> n >> m;
  long long a[n];
  map<long long, long long> I{};
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= m;
    I[a[i]]++;
  }
  long long sum[n];
  sum[0] = a[0] % m;
  for (long long i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + a[i];
    sum[i] %= m;
  }
  sort(sum, sum + n);
  long long ans = 0;
  long long count = 1;
  for (long long i = 0; i < n - 1; i++) {
    if (sum[i] == 0) ans++;
    if (sum[i] == sum[i + 1])
      count++;
    else {
      ans += count * (count - 1) / 2;
      count = 1;
    }
  }
  ans += count * (count - 1) / 2;
  cout << ans << endl;
  return 0;
}
