#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int64_t M;
  cin >> N >> M;
  vector<int64_t> A(100010), sum(100010, 0);
  map<int64_t, int> rem_count;
  rem_count[0]++;
  for (int i = 1; i <= (int)(N); i++) {
    cin >> A[i];
    sum[i] = sum[i - 1] + A[i];
    sum[i] %= M;
    rem_count[sum[i]]++;
  }
  int64_t ans = 0;
  for (pair<int64_t, int> p : rem_count) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}
