#include <bits/stdc++.h>
using namespace std;
map<int, int> fr;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> v[i];
  int sol = 0;
  fr[0]++;
  for (int i = 1; i <= n; i++) {
    v[i] = (v[i - 1] + v[i]) % m;
    sol += fr[v[i]];
    fr[v[i]]++;
  }
  cout << sol;
  return 0;
}
