#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long ncr[10010][10010];
void nCr(int n) {
  for (long long i = 0; i < n + 1; i++)
    for (long long j = 0; j < i + 1; j++) {
      if (j == 0)
        ncr[i][j] = 1;
      else
        ncr[i][j] = ncr[i - 1][j] + ncr[i - 1][j - 1];
    }
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<long long> sum(n + 1, 0);
  for (long long i = 1; i < n + 1; i++) sum[i] = sum[i - 1] + a[i - 1];
  long long debug = 0;
  ;
  map<long long, long long> make_pair;
  for (long long i = 0; i < n + 1; i++) make_pair[sum[i] % m]++;
  nCr(n + 1);
  long long ans = 0;
  for (auto itr = make_pair.begin(); itr != make_pair.end(); itr++) {
    if (itr->second < 2) continue;
    ans += ncr[itr->second][2];
  }
  cout << ans << endl;
  ;
}
