#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 0, 0}, dy[] = {0, 1, 0, -1, 0};
int n, m, a[100000], b, c, t;
long long int s;
map<int, int> ml, mr;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    t = (t + a[i]) % m;
  }
  ml[0]++;
  for (int i = 0; i < n; i++) {
    b = (b + a[i]) % m;
    ml[b]++;
  }
  s += ml[t];
  for (int i = n - 1; i >= 0; i--) {
    c = (c + a[i]) % m;
    s += ml[(t - c + m) % m];
  }
  cout << (int)(s - n - 1) / 2;
  return 0;
}
