#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int suma[100000];
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    suma[i] = (suma[i - 1] + a) % m;
  }
  int ans = 0;
  map<int, int> cnt;
  cnt[0] = 1;
  for (int i = 0; i < n; i++) {
    if (cnt.find(suma[i]) != cnt.end()) {
      ans += cnt[suma[i]];
      cnt[suma[i]]++;
    } else {
      cnt[suma[i]] = 1;
    }
  }
  cout << ans << endl;
}
