#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n), ps(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ps[i] = a[i];
    if (i) ps[i] += ps[i - 1];
    ps[i] %= m;
  }
  long long ans = 0;
  auto x = ps.begin();
  for (int i = 0; i < n; ++i) {
    ans += count(ps.begin(), x, ps[i]);
    if (ps[i]) ans--;
    x++;
  }
  cout << ans + n;
}
