#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
int N, M, A[MAX_N];
int dp[MAX_N + 1];
std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,
                                        std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}
void solve() {
  long long res = 0;
  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    dp[i + 1] = dp[i] + A[i];
    int temp = dp[i + 1] % M;
    mp[temp] = mp[temp] + 1;
  }
  for (auto const &val : mp) {
    res += comb(val.second, 2)[val.second][2];
    if (val.first == 0) {
      res += val.second;
    }
  }
  printf("%lld\n", res);
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] = A[i] % M;
  }
  solve();
  return 0;
}
