#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long A[100010];
map<long long, long long> acc;
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> A[i];
  acc[0] = 1;
  long long sum = 0;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    long long mod = sum % M;
    ans += acc[mod];
    acc[mod] += 1;
    sum += A[i];
  }
  cout << ans << endl;
  return 0;
}
