#include <bits/stdc++.h>
using namespace std;
int a[100005];
int tmp[100005];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 1; i <= N; i++)
    cin >> a[i], a[i] += a[i - 1], a[i] %= M, tmp[i] = a[i];
  sort(tmp + 1, tmp + N + 1);
  for (int i = 1; i <= N; i++)
    a[i] = lower_bound(tmp + 1, tmp + N + 1, a[i]) - tmp - 1;
  for (int i = 0; i <= N; i++) tmp[i] = 0;
  for (int i = 0; i <= N; i++) tmp[a[i]]++;
  long long ac = 0;
  for (int i = 0; i <= N; i++) {
    if (tmp[i]) {
      ac += tmp[i] * (tmp[i] - 1) / 2;
    }
  }
  cout << ac;
  return 0;
}
