#include <bits/stdc++.h>
using namespace std;
int n;
int m;
int a[100005];
int t;
map<int, long long> g;
map<int, long long>::iterator it;
int v[100005];
int cnt = 0;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> t;
    a[i] = (t + a[i - 1] + m) % m;
    it = g.find(a[i]);
    if (it != g.end()) {
      v[it->second]++;
    } else {
      g[a[i]] = cnt;
      v[cnt++] = 1;
    }
  }
  v[g[0]]++;
  long long ans = 0;
  for (int i = 0; i < cnt; i++) {
    ans += (v[i] * (v[i] - 1)) / 2;
  }
  cout << ans << endl;
}
