#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long M;
  vector<long long> A;
  A.push_back(0);
  long long a_tmp;
  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    cin >> a_tmp;
    A.push_back(a_tmp);
  }
  unordered_map<int, long long> mp;
  long long sum_tmp, r;
  for (int i = 0; i < N + 1; ++i) {
    sum_tmp = 0;
    for (int j = 0; j < i; ++j) {
      sum_tmp += A[j];
    }
    r = sum_tmp % M;
    mp.insert(make_pair(i, r));
  }
  long long counter = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N + 1; ++j) {
      if (mp[i] == mp[j]) {
        counter++;
      }
    }
  }
  cout << counter << endl;
}
