#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  vector<int> acc(N + 1);
  cin >> N >> M;
  acc[0] = 0;
  int tmp;
  map<int, int> mp;
  mp[0]++;
  for (int i = 1; i <= N; i++) {
    cin >> tmp;
    acc[i] = (acc[i - 1] + tmp) % M;
    mp[acc[i]]++;
  }
  long long ans = 0;
  for (auto m : mp) {
    ans += m.second * (m.second - 1) / 2;
  }
  cout << ans << endl;
}
