#include <bits/stdc++.h>
using namespace std;
long long n, m, a[101010], d[101010] = {0};
bool b[101010] = {0};
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= m;
  }
  for (int i = 0; i < n; i++) {
    long long c = 0;
    for (int j = i; j < n; j++) {
      c += a[j];
      if (c % m == 0) {
        d[i] = j + 1;
        break;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long cnt = 0;
    int j = i;
    while (!b[j] && d[j] != 0) {
      cnt++;
      ans += cnt;
      b[j] = 1;
      j = d[j];
    }
  }
  cout << ans << endl;
  return 0;
}
