#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int, int> > qu2;
priority_queue<int> pq;
static const int NIL = -1;
static const int INF = 1000000007;
class UnionFind {
 public:
  vector<int> Parent;
  UnionFind(int n) { Parent = vector<int>(n, -1); }
  int root(int A) {
    if (Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  int size(int A) { return -Parent[root(A)]; }
  int connect(int A, int B) {
    A = root(A);
    B = root(B);
    if (A == B) {
      return false;
    }
    if (size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
};
double dot_product(complex<double> a, complex<double> b) {
  return (conj(a) * b).real();
}
double cross_product(complex<double> a, complex<double> b) {
  return (conj(a) * b).imag();
}
complex<double> projection(complex<double> p, complex<double> b) {
  return b * dot_product(p, b) / norm(b);
}
long long f[2001];
long long pw(long long x, long long y) {
  long long a = 1;
  while (y) {
    if (y & 1) {
      a = a * x % 1000000007;
    }
    x = x * x % 1000000007;
    y /= 2;
  }
  return a;
}
long long modinv(long long x) { return pw(x, 1000000007 - 2); }
long long comb(int n, int r) {
  if (n < r) {
    return 0;
  }
  return f[n] * modinv(f[r]) % 1000000007 * modinv(f[n - r]) % 1000000007;
}
struct BIT {
  vector<int> dat;
  int sz;
  BIT(int n) {
    for (sz = 1; sz < n; sz *= 2)
      ;
    dat.resize(++sz);
  }
  int q(int n) {
    int ret = 0;
    for (int i = n; i > 0; i -= i & -i) ret += dat[i];
    for (int i = n; i < sz; i += i & -i) dat[i]++;
    return ret;
  }
};
int main() {
  f[0] = 1;
  f[1] = 1;
  for (int i = 2; i < 2001; i++) {
    f[i] = f[i - 1] * i;
  }
  int n, m;
  cin >> n >> m;
  int a[n];
  vector<int> b(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
    a[i] %= m;
    if (i == 0) {
      b[i] = a[i] % m;
    } else {
      b[i] = (b[i - 1] + a[i]) % m;
    }
  }
  long long ans = 1;
  sort(b.begin(), b.end());
  int temp = 1;
  for (int i = 1; i < n; i++) {
    if (b[i] == b[i - 1]) {
      temp++;
      ans += temp;
    } else {
      temp = 0;
      ans += temp;
    }
  }
  cout << ans << endl;
  return 0;
}
