#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (long long(i) = 0; (i) < (n); (i)++) cin >> a[i];
  long long ans = 0;
  vector<long long> sum(n + 1);
  for (long long(i) = 0; (i) < (n + 1); (i)++) {
    sum[i + 1] = sum[i] + a[i];
  }
  map<int, long long> count;
  for (long long(i) = 0; (i) < (n); (i)++) {
    ++count[sum[i + 1] % m];
  }
  for (long long(i) = 0; (i) < (n); (i)++) {
    int idx = (m - (sum[n] - sum[i + 1]) % m) % m;
    if (count[idx] > 0) ans += count[idx];
    --count[sum[i + 1] % m];
  }
  cout << ans << endl;
}
