#include <bits/stdc++.h>
using namespace std;
static long long gcd(long long a, long long b) {
  long long amari = a % b;
  long long c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}
static long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a;
  vector<long long> b;
  for (long long i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  b.push_back(a[0] % m);
  for (long long i = 1; i < n; i++) {
    b.push_back((b[i - 1] + a[i]) % m);
  }
  map<long long, long long> cnt;
  for (long long i = 0; i < n - 1; i++) {
    cnt[b[i]]++;
  }
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j < i; j++) {
      cnt[b[i] - b[j]]++;
    }
  }
  cnt[0]++;
  cout << cnt[0];
}
