#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int input;
  long long int answer = 0;
  cin >> n >> m;
  vector<long long int> a(n + 1, 0);
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> input;
    a[i] = a[i - 1] + input;
    a[i] %= m;
  }
  sort(a.begin(), a.end());
  int cnt = 1;
  for (int i = 1; i < n + 1; i++) {
    if (a[i] == a[i - 1]) {
      cnt++;
    } else {
      answer += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  answer += cnt * (cnt - 1) / 2;
  cout << answer << endl;
  return 0;
}
