#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, M;
  cin >> N >> M;
  int ans = 0;
  vector<int> B(N, 0);
  unordered_multimap<int, int> mmp;
  mmp.insert(make_pair(0, 0));
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    if (i == 0) {
      B[i] = a % M;
      mmp.insert(make_pair(B[i], i));
      ans += mmp.count(B[i]) - 1;
    } else {
      B[i] = B[i - 1] + a;
      B[i] %= M;
      mmp.insert(make_pair(B[i], i));
      ans += mmp.count(B[i]) - 1;
    }
  }
  cout << ans << endl;
}
