#include <bits/stdc++.h>
using namespace std;
int MOD;
long long modinv(long long a) {
  long long b = MOD, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}
long long exp(int a, int b) {
  long long res = 1;
  long long sum = a;
  while (b) {
    if (b & 1) res = (res * sum) % MOD;
    sum = (sum * sum) % MOD;
    b >>= 1;
  }
  return res;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> line(M, 0);
  line[0] = 1;
  long long ans = 0;
  long long sum = 0;
  for (int i = 0; i < (N); ++i) {
    long long d;
    cin >> d;
    sum += d;
    ans += line[sum % M];
    ++line[sum % M];
  }
  cout << ans << endl;
}
