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