#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  int s[n][n];
  for (int i = 0; i < n; ++i) s[i][i] = a[i] % m;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      s[i][j] = (s[i][j - 1] + a[j] % m) % m;
    }
  }
  int ans = 0;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      if (s[i][j] == 0) ++ans;
      if (ans >= 1e9) {
        v.push_back(ans);
        ans = 0;
      }
    }
  }
  if (ans == 0) {
    long long cnt = v.size();
    if (v.size() >= 1)
      cout << cnt << "000000000" << endl;
    else
      cout << "0" << endl;
  } else {
    if (v.size() == 0) {
      cout << ans << endl;
    } else {
      long long cnt = v.size();
      cout << cnt;
      int keta = 0;
      int cp = ans;
      while (cp) {
        ++keta;
        cp = cp / 10;
      }
      for (int i = 0; i < 9 - keta; ++i) cout << "0";
      cout << ans << endl;
    }
  }
}
