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