#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  map<long long, long long> rem;
  rem[0]++;
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    sum += a;
    rem[sum % m]++;
  }
  long long ans = 0;
  for (long long i = 0; i < rem.size(); i++) {
    ans += (rem[i] - 1) * rem[i] / 2;
  }
  cout << ans << endl;
}
