#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000;
bool vis[maxn];
map<long long, long long> mm;
int n;
long long m;
int main() {
  while (cin >> n >> m) {
    long long num, sum = 0, ans = 0;
    mm.clear();
    for (int i = 1; i <= n; i++) {
      cin >> num;
      sum += num;
      sum %= m;
      if (sum == 0) mm[0]++;
      ans += mm[sum];
      mm[sum]++;
    }
    cout << ans << endl;
  }
  return 0;
}
