#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
long long n, m;
long long a[MAXN];
long long sum[MAXN];
map<long long, int> cnt;
void solve() {
  for (int i = 0; i < n; i++) {
    sum[i + 1] = (sum[i] + a[i]) % m;
    cnt[sum[i + 1]]++;
  }
  long long ans = 0;
  for (const auto& x : cnt) {
    ans += x.second * (x.second - 1) / 2;
    if (x.first == 0) {
      ans += x.second;
    }
  }
  cout << ans << endl;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  solve();
}
