#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a[i] = t % m;
  }
  int b[n];
  map<int, int> mp;
  b[0] = a[0];
  for (int i = 1; i < n; i++) {
    b[i] = (b[i - 1] + a[i]) % m;
    mp[b[i]] = 0;
  }
  for (int i = 0; i < n; i++) {
    mp[b[i]]++;
  }
  long long ans = 0;
  for (auto x : mp) {
    if (x.first == 0) ans += x.second;
    ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
