#include <bits/stdc++.h>
using namespace std;
long long N, M;
vector<long long> A;
long long combination(int n, int m) {
  long long ans = 1;
  for (long long i = 0; i < m; i++) {
    ans *= n - i;
    ans /= i + 1;
  }
  return ans;
}
void solve() {
  vector<int> m(M, 0);
  set<long long> s;
  long long x = 0;
  for (int i = 0; i <= N; i++) {
    x += A[i];
    m[x % M]++;
    s.insert(x % M);
  }
  long long ans = 0;
  for (auto e : s) {
    if (2 <= m[e]) ans += combination(m[e], 2);
  }
  cout << ans << endl;
}
int main() {
  cin >> N >> M;
  A.resize(N + 1);
  A[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  solve();
  return 0;
}
