#include <bits/stdc++.h>
typedef struct _node {
  int key;
  long counter;
  struct _node *parent, *left, *right;
} node;
typedef struct _tree {
  node *root;
} tree;
node *NIL;
node *make_node(int key) {
  node *n = (node *)malloc(sizeof(node));
  n->key = key;
  n->counter = 1;
  n->parent = NIL;
  n->left = NIL;
  n->right = NIL;
  return n;
}
void insert(tree *t, int key) {
  node *prev, *n_node = make_node(key);
  node *n = t->root;
  if (n == NIL) {
    t->root = n_node;
    return;
  }
  while (1) {
    if (n == NIL) {
      if (prev->key < key) {
        prev->right = n_node;
        n_node->parent = prev;
        return;
      } else {
        prev->left = n_node;
        n_node->parent = prev;
        return;
      }
    } else if (n->key == key) {
      n->counter++;
      return;
    } else if (n->key < key) {
      prev = n;
      n = n->right;
    } else {
      prev = n;
      n = n->left;
    }
  }
}
long long counter(node *n) {
  long long val;
  if (n == NIL) {
    return 0;
  }
  if (n->counter == 0) {
    val = counter(n->left) + counter(n->right);
  } else if (n->counter >= 1) {
    val = counter(n->left) + counter(n->right) +
          ((n->counter - 1) * n->counter) / 2;
  }
  if (n->key == 0) {
    val += n->counter;
  }
  return val;
}
int main(void) {
  int i, N, M, val, sum = 0;
  tree *t = (tree *)malloc(sizeof(tree));
  t->root = NIL;
  scanf("%d %d", &N, &M);
  for (i = 0; i < N; i++) {
    scanf("%d", &val);
    sum = (sum + val) % M;
    insert(t, sum);
  };
  long long all = counter(t->root);
  printf("%lld\n", all);
  return 0;
}
