#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long pow(long long a, long long b) {
  long long k = b % 30000, h = b / 30000, s = 1;
  for (int i = 0; i < 30000; i++) s = (s * a) % 1000000007;
  long long j = 1;
  if (h != 0)
    for (int i = 0; i < h; i++) j = j * s % 1000000007;
  if (k != 0)
    for (int i = 0; i < k; i++) j = j * a % 1000000007;
  return (j);
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long dp[100010];
  dp[0] = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    sum = sum % m;
    dp[i + 1] = sum;
  }
  vector<long long> b(m);
  for (int i = 0; i <= n; i++) {
    b[dp[i]]++;
  }
  int count = 0;
  for (int i = 0; i < m; i++) {
    count += b[i] * (b[i] - 1) / 2;
  }
  cout << count << endl;
}
