#include <bits/stdc++.h>
using namespace std;
long long n, t, m, k;
long long ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(2);
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i], a[i] %= m;
  map<int, int> mp;
  mp[0] = 1;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    ans += mp[(m - a[i]) % m];
    sum += a[i];
    sum %= m;
    mp[sum]++;
  }
  cout << ans;
}
bool isPrime(long long g) {
  if ((g % 2 == 0 && g > 2) || g == 1) return 0;
  for (long long i = 3; i * i <= g; i += 2)
    if (g % i == 0) return 0;
  return 1;
}
