#include <bits/stdc++.h>
using namespace std;
int sum(int a) {
  int A = 0;
  for (int i = 0; i < a; i++) A += i + 1;
  return A;
}
int main() {
  int N, M;
  int ans = 0;
  cin >> N >> M;
  vector<int> box(N + 1);
  for (int i = 1; i < N + 1; i++) cin >> box.at(i);
  for (int i = 1; i < N + 1; i++) box.at(i) += box.at(i - 1);
  map<long long, int> mp;
  for (int i = 0; i < N + 1; i++) mp[box.at(i) % M]++;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    itr->second = sum(itr->second - 1);
    ans += itr->second;
  }
  cout << ans << endl;
  return 0;
}
