#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int a, dp;
  vector<int> mcnt(m, 0);
  long long ans = 0;
  for (int i = 0, i_len = (n); i < i_len; i++) {
    int a;
    cin >> a;
    if (i == 0) {
      dp = a % m;
    } else {
      dp = (dp + a) % m;
    }
    mcnt[dp]++;
  }
  for (int i = 0, i_len = (m); i < i_len; i++) {
    if (i == 0) {
      ans = ans + mcnt[i];
    }
    ans += (long long)mcnt[i] * (mcnt[i] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
