#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long N, M;
  long ans = 0;
  cin >> N >> M;
  vector<long> A;
  for (long i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  unordered_map<long, long> before;
  for (auto current : A) {
    unordered_map<long, long> after;
    for (auto b : before) {
      after[(b.first + current) % M] = b.second;
    }
    after[current % M]++;
    ans += after[0];
    before = after;
  }
  cout << ans << endl;
  return 0;
}
