#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100010];
int main() {
  cin >> n >> m;
  int i, j;
  for (i = 1; i <= n; i++) cin >> a[i];
  a[1] %= m;
  for (i = 2; i <= n; i++) a[i] = (a[i - 1] + a[i]) % m;
  sort(a + 1, a + n + 1);
  int ans = 0;
  int k = 1;
  for (i = 2; i <= n; i++) {
    if (a[i] == a[i - 1] && a[i] != 0)
      k++;
    else {
      ans += (k * (k - 1)) / 2;
      k = 1;
    }
  }
  ans += (k * (k - 1)) / 2;
  k = 0;
  for (i = 1; i <= n; i++)
    if (a[i] == 0) k++;
  ans += (k * (k + 1)) / 2;
  cout << ans << endl;
  return 0;
}
