#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n + 1];
  a[0] = 0;
  int z = 0;
  long long x = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = (a[i] + z) % m;
    z = a[i];
  }
  int c;
  for (int i = 0; i < m; i++) {
    c = 0;
    for (int j = 0; j <= n; j++) {
      if (a[j] == i) {
        c = c + 1;
      }
    }
    x += (c * (c - 1) / 2);
  }
  cout << x << endl;
}
