#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<long long> a(n + 1);
  a[0] = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) a[i] = (a[i] + a[i - 1]) % m;
  sort(a.begin(), a.end());
  long long ans = 0;
  int tmp = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] != a[i + 1]) {
      ans += tmp * (tmp - 1) / 2;
      tmp = 1;
    } else
      tmp++;
  }
  ans += tmp * (tmp - 1) / 2;
  cout << ans << endl;
}
