#include <bits/stdc++.h>
using namespace std;
long long int n, m;
int main() {
  cin >> n >> m;
  long long int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int dp[n + 1][m + 1];
  for (int i = 0; i < m; i++) {
    dp[0][i] = 0;
  }
  int count = 0;
  for (int i = 1; i <= n; i++) {
    int rem = a[i - 1] % m;
    for (int j = 0; j < m; j++) {
      if (j == 0) {
        dp[i][rem] = dp[i - 1][j] + 1;
      } else {
        dp[i][(j + rem) % m] = dp[i - 1][j];
      }
    }
    count += dp[i][0];
  }
  cout << count << endl;
  return 0;
}
