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