#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  long ans = 0, temp = 0, c = 0;
  ;
  cin >> N >> M;
  int A[N], B[N];
  int t = 1;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    A[i] = A[i] % M;
    if (A[i] == 0) {
      ans++;
    } else {
      B[t] = A[i];
      t++;
    }
  }
  c = ans;
  for (int k = 1; k <= t; k++) {
    for (int s = 2; s <= t - k + 1; s++) {
      temp = 0;
      for (int u = k; u <= k + s - 1; u++) {
        temp = temp + B[u];
      }
      if (temp % M == 0) {
        ans++;
      }
    }
  }
  cout << ans + (c * (c - 1) * (1 / 2)) * (1 + ans) << endl;
  return 0;
}
