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