#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, a[100010], c[100010], ans = 0;
  map<int, int> mp;
  mp[0] = 1;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) {
    c[i + 1] = (c[i] + a[i]) % m;
    mp[c[i + 1]]++;
  }
  for (auto p : mp) {
    ans += (p.second - 1) * p.second / 2;
  }
  cout << ans << endl;
  return 0;
}
