#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const bool test = true;
long long dx[] = {1, 0, -1, 0};
long long dy[] = {0, 1, 0, -1};
const long long INF = (long long)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (long long)1e9 + 7;
const double eps = 1e-10;
long long sgn(const long double &r) { return (r > eps) - (r < -eps); }
long long sgn(const long double &a, const long double &b) { return sgn(a - b); }
const long long MAX = (long long)2e5 + 5;
vector<string> split(const string &str, char sep) {
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep)) {
    v.push_back(buffer);
  }
  return v;
}
template <typename T>
vector<T> sorted(vector<T> &a) {
  auto res = a;
  sort(res.begin(), res.end());
  return res;
}
template <typename T>
void vec_print(vector<T> &a) {
  for (auto &v : a) cout << v << " ";
  cout << endl;
}
template <class InputIterator>
long long sum(InputIterator begin, InputIterator end) {
  return accumulate(begin, end, 0ll);
}
template <typename T>
T gcd(T a, T b) {
  T c;
  while (a != 0) {
    c = a;
    a = b % a;
    b = c;
  }
  return b;
}
long long pow(long long a, long long b) {
  long long res = 1;
  for (long long i = 0; i < (long long)(b); ++i) res *= a;
  return res;
}
class Solver {
 public:
  long long H, W;
  long long N, M;
  vector<long long> A, B, C;
  bool ng(long long y, long long x) {
    return y < 0 || y >= H || x < 0 || x >= W;
  }
  void solve_slow() {
    long long ans = 0;
    for (long long l = 0; l < (long long)(N); ++l) {
      for (long long r = (l); r < (long long)(N); ++r) {
        long long cur = 0;
        for (long long i = (l); i < (long long)(r + 1); ++i) cur += A[i];
        if (cur % M == 0) {
          cerr << "l"
               << " = " << (l) << " ";
          cerr << "r"
               << " = " << (r) << " " << endl;
          ;
          ans += 1;
        }
      }
    }
    cout << ans << endl;
  }
  void solve() {
    cin >> N >> M;
    A.resize(N);
    for (long long i = 0; i < (long long)(N); ++i) cin >> A[i];
    solve_slow();
    B.resize(N);
    B[0] = A[0];
    for (long long i = 0; i < (long long)(N - 1); ++i)
      B[i + 1] = B[i] + A[i + 1];
    for (long long i = 0; i < (long long)(N); ++i) B[i] %= M;
    vec_print(B);
    C = sorted(B);
    vec_print(C);
    long long ans = 0;
    for (long long i = 0; i < (long long)(N); ++i) {
      long long v = C[i];
      long long v2 = M - v;
      if (v2 == M) v2 = 0;
      long long cnt = upper_bound(C.begin(), C.end(), v) -
                      lower_bound(C.begin(), C.end(), v);
      if (v == 0) cnt += 1;
      if (v != 0) cnt -= 1;
      cerr << cnt << " ";
      ans += cnt;
    }
    cerr << endl;
    ans /= 2;
    cout << ans << endl;
  }
};
signed main() {
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  return 0;
}
