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