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