#include <bits/stdc++.h>
using namespace std;
int combination(int n, int r) {
  long long ans = 1;
  for (int i = n; i > n - r; i--) ans *= i;
  for (int i = r; i >= 1; i--) ans /= i;
  return (int)ans;
}
int main() {
  int n, m, a[100000];
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  map<int, int> table;
  table[0] = 1;
  int bi = 0;
  for (int i = 0; i < n; i++) {
    bi = (bi + a[i]) % m;
    if (table.find(bi) == table.end()) {
      table[bi] = 1;
    } else {
      table[bi] = table[bi] + 1;
    }
  }
  long long ans = 0;
  for (auto element : table) {
    if (element.second >= 2) ans += combination(element.second, 2);
  }
  cout << ans << endl;
}
