#include <bits/stdc++.h>
using namespace std;
long long subCount(long long arr[], long long n, long long k) {
  long long mod[k];
  memset(mod, 0, sizeof(mod));
  long long cumSum = 0;
  for (long long i = 0; i < n; i++) {
    cumSum += arr[i];
    mod[((cumSum % k) + k) % k]++;
  }
  long long result = 0;
  for (long long i = 0; i < k; i++)
    if (mod[i] > 1) result += (mod[i] * (mod[i] - 1)) / 2;
  result += mod[0];
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  cout << subCount(arr, n, m) << "\n";
}
