#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> remain;
  int sum = 0, ele = 0, result = 0;
  for (int i = 0; i < n; ++i) {
    cin >> ele;
    sum += ele;
    sum %= m;
    if (sum == 0) result += 1;
    result += remain[sum];
    remain[sum]++;
  }
  cout << result << endl;
  return 0;
}
