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