#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int A[100005], B[100005];
  int n, m;
  cin >> n >> m;
  int x[m];
  for (int i = 0; i < m; i++) {
    x[i] = 0;
  }
  long long ans = 0;
  B[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    B[i] = (B[i - 1] + A[i]) % m;
    x[B[i]]++;
  }
  x[0]++;
  for (int i = 0; i < m; i++) {
    ans += x[i] * (x[i] - 1) / 2;
  }
  cout << ans << endl;
}
