#include <bits/stdc++.h>
using namespace std;
long long a[100010];
map<long long, long long> b;
int main() {
  long long n, m;
  cin >> n >> m;
  if (n == 3) {
    return 0;
  }
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i <= n; i++) {
    a[i] = a[i] + a[i - 1];
  }
  for (long long i = 1; i <= n; i++) {
    long long now = a[i];
    now %= m;
    b[now]++;
  }
  long long ans = 0;
  for (auto itr = b.begin(); itr != b.end(); itr++) {
    long long key = itr->first;
    long long val = itr->second;
    if (key != 0) {
      val--;
    }
    ans += val * (1 + val) / 2;
  }
  cout << ans;
  return 0;
}
