#include <bits/stdc++.h>
using namespace std;
map<int, long long> mp;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  long long psum = 0;
  mp[0]++;
  for (int i = 1; i <= n; i++) {
    int can;
    cin >> can;
    psum += can;
    int rem = int(psum % m);
    mp[rem]++;
  }
  long long ans = 0;
  for (auto u : mp) {
    int er = u.second;
    ans += ((er - 1) * er / 2);
  }
  cout << ans << "\n";
  return 0;
}
