#include <bits/stdc++.h>
using namespace std;
int dy[5] = {0, 0, 1, -1, 0};
int dx[5] = {1, -1, 0, 0, 0};
int main(void) {
  long long int n, m;
  long long int a[100001];
  long long int count = 0;
  long long int now;
  cin >> n >> m;
  for (int i = (1); i <= (n); i++) {
    cin >> a[i];
  }
  vector<long long int> dp(n, 0);
  dp[0] = a[1];
  dp[0] %= m;
  for (int i = (1); i <= (n - 1); i++) {
    dp[i] = dp[i - 1] + a[i + 1];
    dp[i] %= m;
  }
  sort(dp.begin(), dp.end());
  now = 1;
  for (int i = (0); i <= (n - 2); i++) {
    if (dp[i] == dp[i + 1]) {
      now++;
    } else {
      count += (now) * (now - 1) / 2;
      if (dp[i] == 0) {
        count += now;
      }
      now = 1;
    }
  }
  count += (now) * (now - 1) / 2;
  cout << count << endl;
  return 0;
}
