#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  unordered_map<int, int> um;
  long long s[n + 1];
  s[0] = 0;
  for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
  for (int i = 0; i < n + 1; i++) {
    um[s[i] % m]++;
  }
  long long sum = 0;
  for (auto x : um) {
    if (x.second == 1) continue;
    sum += (x.second * (x.second - 1)) / 2;
  }
  cout << sum << endl;
  return 0;
}
