#include <bits/stdc++.h>
using namespace std;
void Main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < (N); ++i) cin >> A[i];
  vector<long long> S(N, 0);
  map<long long, long long> mp;
  mp[0] = 1;
  for (int i = 0; i < (N); ++i) {
    S[i + 1] = S[i] + A[i];
    ++mp[S[i + 1] % M];
  }
  long long res = 0;
  for (auto p : mp) {
    res += (p.second * (p.second - 1)) / 2;
  }
  cout << res << endl;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
