#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, mod;
  cin >> n >> mod;
  unordered_map<int64_t, int64_t> count;
  int64_t total = 0;
  int64_t sum = 0;
  for (int64_t i = 0; i < n; i += 1) {
    int64_t num;
    cin >> num;
    num %= mod;
    if (i > 0) {
      sum += num;
      sum %= mod;
    }
    if (sum == 0) {
      total += 1;
    }
    total += count[sum];
    count[sum] += 1;
  }
  cout << total << "\n";
  return 0;
}
