#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX / 10;
const long long MOD = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> As(N + 1, 0);
  for (long long i = 0; (i) < (N); ++(i)) {
    int A;
    cin >> A;
    As[i + 1] = As[i] + A;
    As[i + 1] %= M;
  }
  sort(As.begin(), As.end());
  long long ans = 0;
  for (long long i = 0; (i) < (N + 1); ++(i)) {
    int j = i;
    while (j <= N + 1 && As[j] == As[i]) {
      j++;
    }
    ans += (j - i) * (j - i - 1) / 2;
    i = j - 1;
  }
  cout << ans << endl;
  return 0;
}
