#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int a[(int)1e5];
int rui[(int)1e5 + 1];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int tmp;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    a[i] = tmp % m;
  }
  for (int i = 1; i <= n; i++) {
    rui[i] = (rui[i - 1] + a[i]) % m;
  }
  sort(rui, rui + n + 1);
  long long ans = 0;
  for (int i = 0; i < n + 1; i++) {
    auto up = upper_bound(rui + i, rui + n + 1, rui[i]);
    ans += up - (rui + i) - 1;
  }
  cout << ans << "\n";
  return 0;
}
