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