#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool prime(long long p) {
  for (long long i = 2; i <= sqrt(p); i++) {
    if (!p % i) return false;
  }
  return true;
}
long long n, m, a[100000], ans = 0;
map<long long, long long> mp;
signed main() {
  cin >> n >> m >> a[0];
  for (long long i = 1; i < n; i++) {
    cin >> a[i];
    a[i] = (a[i] + a[i - 1]) % m;
  }
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    mp[a[i]]++;
    ans += mp[a[i]];
  }
  cout << ans << endl;
  return 0;
}
