#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
};
const int INF = 100000000;
long long int N, M, A[100010], B[100010], ans = 0;
long long int comb(long long int n, long long int r) {
  long long int seki = 1;
  for (int i = n; n - r < i; i--) {
    seki *= i;
  }
  for (int i = 1; i <= r; i++) {
    seki /= i;
  }
  return seki;
}
int main() {
  long long int count = 0;
  cin >> N >> M;
  for (int i = 0; i < (N); i++) {
    cin >> A[i];
  }
  for (int i = 0; i < (N); i++) {
    A[i + 1] += A[i];
    B[i + 1] = A[i];
  }
  for (int i = 0; i < (N + 1); i++) {
    B[i] %= M;
  }
  sort(B, B + N + 1);
  for (int i = 0; i < (N + 2); i++) {
    if (B[i] != B[i + 1]) {
      count++;
      ans += comb(count, 2);
      count = 0;
    } else {
      count++;
    }
  }
  cout << ans << endl;
  return 0;
}
