#include <bits/stdc++.h>
using namespace std;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T>
void chmin(T& a, const T& b) {
  a = std::min(a, b);
}
template <class T>
void chmax(T& a, const T& b) {
  a = std::max(a, b);
}
int main() {
  int N, M;
  cin >> N >> M;
  long long int box[N + 2];
  box[0] = 0;
  long long int temp;
  for (int i = 1; i <= N; ++i) {
    cin >> temp;
    long long int add = box[i - 1] + temp;
    if (add >= M) {
      box[i] = add % M;
    } else
      box[i] = add;
  }
  long long int ans = 0;
  for (int i = (0); i < (N + 1); ++i) {
    for (int j = (i + 1); j < (N + 1); ++j) {
      if (box[i] == box[j]) ++ans;
    }
  }
  cout << ans << endl;
}
