#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> A(N + 1);
  A[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    A[i] += A[i - 1];
    A[i] = A[i] % M;
  }
  long long ans = 0;
  for (int i = 0; i <= N; i++) {
    if (A[i] == -1) {
      continue;
    }
    int cnt = 1;
    int num = A[i];
    A[i] = -1;
    for (int j = i + 1; j <= N; j++) {
      if (A[j] == num) {
        cnt++;
        A[j] = -1;
      }
    }
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
}
