#include <bits/stdc++.h>
using namespace std;
vector<int> t;
int main() {
  int N, M;
  int p, cnt;
  long ans;
  cin >> N >> M;
  t.push_back(0);
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    t.push_back((t.back() + a) % M);
  }
  sort(t.begin(), t.end());
  t.push_back(-1);
  ans = 0;
  cnt = 0;
  for (int i = 1; i < t.size(); ++i) {
    if (t[i] == t[i - 1]) {
      ++cnt;
    } else {
      if (cnt > 1) {
        ans += (long)cnt * (cnt + 1) / 2;
        cnt = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
