#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, sum = 0, ans = 0;
  cin >> n >> m;
  int f[n];
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    sum += c;
    sum %= m;
    f[i] = sum;
  }
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++)
      if ((f[j] - f[i]) % m == 0) ans++;
  cout << ans;
}
