#include <bits/stdc++.h>
using namespace std;
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
long long gcd(long long a, long long b) {
  if (a < b) {
    return gcd(b, a);
  } else if (a % b) {
    return gcd(b, a % b);
  } else {
    return b;
  }
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long prime(long long x) {
  long long i;
  if (x < 2)
    return 0;
  else if (x == 2)
    return 1;
  if (x % 2 == 0) return 0;
  for (i = 3; i * i <= x; i += 2) {
    if (x % i == 0) return 0;
  }
  return 1;
}
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N + 10);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
  }
  long long res = 0;
  long long sum = 0;
  long long right = 0;
  for (long long left = 0; left < N; left++) {
    while (right < N && (sum % M) == 0) {
      sum += A[right];
      ++right;
    }
    res += (right - left);
    if (left == right)
      ++right;
    else {
      sum -= A[left];
    }
  }
  cout << res << endl;
}
