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