#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
long long S[10000];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> S[i], S[i] %= M;
  for (int i = 1; i < N; i++) (S[i] += S[i - 1]) %= M;
  long long ans = 0;
  map<int, int> cnt;
  cnt[S[0]]++;
  if (S[0] == 0) ans++;
  for (int i = 1; i < N; i++) {
    ans += cnt[S[i]];
    if (S[i] == 0) ans++;
    cnt[S[i]]++;
  }
  cout << ans << endl;
}
