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