#include <bits/stdc++.h>
using namespace std;
static const double PI = 3.1415926535897932384626433;
static const long long INF = (long long)1 << 55;
static const long long MOD = 1;
long long fact[1000001] = {};
static const long long COMB_SIZE = 1000000;
void factorial(long long f) {
  fact[0] = fact[1] = 1;
  for (long long i = 1; i < COMB_SIZE; i++) fact[i] = fact[i - 1] * i % MOD;
}
long long POW(long long n, long long p) {
  if (p == 0) return 1;
  if (p == 1) return n;
  long long t = POW(n, p / 2);
  if (p & 1)
    return (t * t % MOD) * n % MOD;
  else
    return t * t % MOD;
}
long long Combination(long long n, long long r) {
  return ((fact[n] * (POW(fact[r], MOD - 2) % MOD)) % MOD *
          POW(fact[n - r], MOD - 2)) %
         MOD;
}
long long A[100001] = {};
long long S[100001] = {};
long long T[100001] = {};
map<long long, long long> mp;
int main() {
  long long N, M;
  cin >> N >> M;
  for (long long i = 1; i <= N; i++) {
    long long a;
    cin >> a;
    A[i] = a;
    S[i] = S[i - 1] + a;
    T[i] = S[i] % M;
    mp[T[i]]++;
  }
  long long cnt_0 = 0;
  for (long long i = 1; i <= N; i++) {
    if (T[i] == 0) cnt_0++;
  }
  factorial(1000000);
  long long cnt = 0;
  for (map<long long, long long>::iterator it = mp.begin(); it != mp.end();
       it++) {
    if (it->second >= 2) {
      cnt += Combination(it->second, 2);
    }
  }
  cout << cnt_0 + cnt << endl;
  return 0;
}
