#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[100010];
  cin >> n >> m;
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    a[i] += a[i - 1];
    a[i] %= m;
  }
  int ans = 0;
  sort(a, a + n + 1);
  int cnt = 1;
  vector<int> counter;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i - 1]) {
      counter.push_back(cnt);
      cnt = 1;
    } else {
      cnt++;
    }
    if (i == n) {
      counter.push_back(cnt);
    }
  }
  for (int i = 0; i < counter.size(); i++) {
    ans += counter[i] * (counter[i] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
