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