#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n, m, x, a, dp[100001];
  unsigned long long ans = 0;
  dp[0] = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a = x % m;
    if (dp[i] + a >= m)
      dp[i + 1] = dp[i] + a - m;
    else
      dp[i + 1] = dp[i] + a;
    if (dp[i + 1] == 0) ans++;
  }
  for (int i = 2; i <= m; i++)
    for (int j = 1; j < i; j++) {
      if (dp[i] == dp[j]) ans++;
    }
  cout << ans << endl;
  return 0;
}
