#include <bits/stdc++.h>
using namespace std;
long long ans;
long long n, m, h;
struct node {
  long long l, r;
  long long sum;
  long long mid() { return (l + r) / 2; }
} tree[800010];
void buildtree(long long root, long long l, long long r) {
  tree[root].l = l;
  tree[root].r = r;
  tree[root].sum = 0;
  if (l != r) {
    buildtree(2 * root + 1, l, (l + r) / 2);
    buildtree(2 * root + 2, (l + r) / 2 + 1, r);
  }
}
void insert(long long root, long long i, long long v) {
  if (tree[root].l == tree[root].r) {
    tree[root].sum = v % m;
    return;
  }
  tree[root].sum += v;
  tree[root].sum %= m;
  if (i <= tree[root].mid())
    insert(2 * root + 1, i, v);
  else
    insert(2 * root + 2, i, v);
}
long long sum = 0;
void query(long long root, long long s, long long e) {
  if (tree[root].l == s && tree[root].r == e) {
    sum += tree[root].sum;
    sum %= m;
    return;
  }
  if (tree[root].mid() >= e)
    query(2 * root + 1, s, e);
  else if (tree[root].mid() < s)
    query(2 * root + 2, s, e);
  else {
    query(2 * root + 1, s, tree[root].mid());
    query(2 * root + 2, tree[root].mid() + 1, e);
  }
}
int main() {
  cin >> n >> m;
  buildtree(0, 1, n);
  for (long long i = 1; i <= n; i++) {
    cin >> h;
    insert(0, i, h);
  }
  for (long long i = 1; i <= n; i++)
    for (long long j = i; j <= n; j++) {
      sum = 0;
      query(0, i, j);
      if (sum % m == 0) ans++;
    }
  cout << ans << endl;
  return 0;
}
