#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> tree(n, vector<int>(n, -1));
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    tree[0][i] = a % m;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < n - i; j++) {
      tree[i][j] = (tree[i - 1][j] + tree[0][j + i]) % m;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += count(tree[i].begin(), tree[i].end(), 0);
  }
  cout << ans << endl;
}
