#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  int buf = 0;
  map<int, int> acc;
  acc.emplace(0, 1);
  for (int i = 0; i < (int)(n); i++) {
    int b;
    cin >> b;
    buf = (buf + b) % m;
    acc[buf] += 1;
  }
  long long ans = 0;
  for (auto it = acc.begin(); it != acc.end(); it++) {
    int buf = it->second;
    ans += buf * (buf - 1) / 2;
  }
  cout << ans << endl;
}
