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