#include <bits/stdc++.h>
using namespace std;
int n, m;
map<long long, long long> mp;
long long a[100005];
int main() {
  scanf("%d%lld", &n, &m);
  long long res = 0, ans = 0;
  mp[0] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    res = (res + a[i]) % m;
    ans += mp[(m - res) % m];
    mp[res]++;
  }
  cout << ans << endl;
}
