#include <bits/stdc++.h>
using namespace std;
long long subCount(vector<long long> arr, long long n, long long k) {
  vector<long long> mod(k, 0);
  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() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << (long long)subCount(a, n, k) << endl;
  return 0;
}
