#include <bits/stdc++.h>
using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
long long int n, m;
map<long long int, long long int> a;
long long int comb(long long int n, long long int r) {
  std::vector<std::vector<long long>> v(n + 1,
                                        std::vector<long long>(n + 1, 0));
  for (long long int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (long long int j = 1; j < v.size(); j++) {
    for (long long int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}
void solve() {
  long long int ans = 0;
  for (auto pair : a) {
    long long int x = pair.second;
    if (x < 2) {
      continue;
    }
    ans += comb(x, 2);
  }
  cout << ans << endl;
}
signed main() {
  cin >> n >> m;
  long long int sum = 0;
  a[0] = 1;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    sum += x;
    a[sum % m]++;
  }
  solve();
  return 0;
}
