#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> a, imos;
int main() {
  cin >> n >> m;
  long long ret = 0;
  for (signed long long i = 0; i < (n); i++) {
    long long h;
    cin >> h;
    a.push_back(h);
  }
  imos.push_back(0);
  for (signed long long i = 0; i < (n); i++) {
    if (i) {
      imos.push_back(imos[i - 1] + a[i]);
      imos[i] %= m;
    }
  }
  sort(imos.begin(), imos.end());
  long long cnt = 0, mae = -114;
  for (signed long long i = 0; i < (n); i++) {
    if (imos[i] == 0) {
      ret++;
    }
    if (mae != imos[i]) {
      ret += ((cnt - 1) * cnt) / 2;
      cnt = 0;
      mae = imos[i];
    }
    cnt++;
  }
  ret += ((cnt - 1) * cnt) / 2;
  cout << ret << endl;
}
