#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long A[101234];
long long ans = 0, a;
map<long long, long long> llmap;
int i, j, k;
int main() {
  cin >> N >> M;
  for (i = 1; i <= N; i++) {
    cin >> A[i];
  }
  a = 0;
  llmap[0] = 1;
  for (i = 0; i <= N; i++) {
    a = (a + A[i]) % M;
    llmap[a]++;
  }
  for (auto l : llmap) {
    ans += (l.second - 1) * l.second / 2;
  }
  cout << ans << endl;
  return 0;
}
