#include <bits/stdc++.h>
using namespace std;
int m, n, a;
long long sum;
int main() {
  while (cin >> n >> m) {
    map<int, int> di;
    sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> a;
      sum += a;
      di[sum % m]++;
    }
    sum = 0;
    for (auto i : di) {
      if (i.first == 0) sum += i.second;
      int num = i.second;
      sum += num * (num - 1) / 2;
    }
    cout << sum << "\n";
  }
  return 0;
}
