#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> da(n);
  for (int i = 0; i < n; i++) {
    cin >> da[i];
  }
  vector<int> co(m, 0), rist(1, 0);
  int me = 0;
  co[0] = 1;
  for (int i = 0; i < n; i++) {
    me = (me + da[i]) % m;
    co[me]++;
    if (co[me] == 1) rist.push_back(me);
  }
  long long ans = 0;
  for (int i = 0; i < rist.size(); i++) {
    ans += (long long)co[rist[i]] * (co[rist[i]] - 1) / 2;
  }
  cout << ans << endl;
}
