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