#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B>
bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> ma;
  int t = 0;
  ma[t]++;
  long long out = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    (t += a) %= m;
    out += ma[(m - t) % m];
    ma[t]++;
  }
  cout << out << endl;
}
