#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
namespace atcoder {
void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
  if (judge_exp) {
    cout << ok << endl;
  } else {
    cout << ng << endl;
  }
}
int ncr(int left, int right) {
  right = min(left - right, right);
  int ans = 1;
  for (int i = 1; i <= right; i++) {
    ans = ans * (left - right + i) / i;
  }
  return ans;
}
const int LIMIT = 1000000256;
const int tenfive = 100100;
}  // namespace atcoder
using namespace atcoder;
int main() {
  int N, M;
  cin >> N >> M;
  vector<lli> num(N);
  for (int i = 0; i < N; i++) {
    cin >> num[i];
  }
  for (int i = 1; i < N; i++) {
    num[i] += num[i - 1];
  }
  lli ans = 0;
  for (int i = 0; i < N; i++) {
    if (num[i] % M == 0) {
      ans++;
    }
    for (int j = i + 1; j < N; j++) {
      if ((num[j] - num[i]) % M == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
