#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int a[4000007], sum[4000007], n, m, ans;
map<int, int> mp;
int main() {
  cin >> n >> m;
  for (register int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = (sum[i - 1] + a[i]) % m;
  }
  for (register int i = 1; i <= n + 1; i++) {
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << ans;
}
