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