#include <bits/stdc++.h>
using namespace std;
const int Nmax = 1e5;
int N;
long long M, A[Nmax];
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<long long> cum(N + 1);
  for (int i = 0; i < N; i++) cum[i + 1] = (cum[i] + A[i]) % M;
  map<long long, int> cnt;
  for (int i = 0; i <= N; i++) cnt[cum[i]]++;
  long long ans = 0;
  for (auto p : cnt) {
    int m = p.second;
    ans += m * (m - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
