#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int a[100001];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= m;
  }
  long long int sum = 0;
  map<long long int, long long int> cnt;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    sum %= m;
    if (a[i] == 0)
      ans++;
    else if (sum == 0)
      ans++;
    if (cnt.find((m - sum) % m) != cnt.end()) ans += cnt[(m - sum) % m];
    if (cnt.find(sum) != cnt.end())
      cnt[sum]++;
    else
      cnt[sum] = 1;
  }
  cout << ans << endl;
}
