#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int i;
  vector<long long int> v;
  long long int a;
  long long int count = 0;
  long long int tmp = 0;
  for (i = 0; i < n; i++) {
    cin >> a;
    a %= m;
    if (i == 0) {
      v.push_back(a);
      tmp = a;
    } else {
      v.push_back((a + tmp) % m);
      tmp = (a + v[i]) % m;
    }
    if (i == 0) {
      if (v[0] == 0) {
        count++;
      }
    } else {
      sort(v.begin(), v.begin() + i);
      count += (upper_bound(v.begin(), v.begin() + i, v[i]) -
                lower_bound(v.begin(), v.begin() + i, v[i]));
      if (v[i] == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}
