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