#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int a[100000];
  for (int i = 0; i < N; i++) scanf("%d", &a[i]);
  int modM[100000];
  modM[0] = a[0] % M;
  for (int i = 1; i < N; i++) modM[i] = (modM[i - 1] + a[i]) % M;
  bool d[100000] = {};
  long long count = 0;
  for (int i = 0; i < N - 1; i++) {
    if (!d[i]) {
      d[i] = true;
      int k = 0;
      if (modM[i] == 0) {
        k = 1;
        count++;
      }
      for (int j = i + 1; j < N; j++) {
        if (modM[j] == modM[i]) {
          d[j] = true;
          k++;
          count += k;
        }
      }
    }
  }
  printf("%lld\n", count);
}
