#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int64_t mod = 1e9 + 7;
int64_t mod1 = 1e9 + 5;
int64_t power(int64_t a, int64_t b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0)
    return power((((a % mod) * (a % mod)) % mod), b / 2) % mod;
  else
    return ((a % mod) * (power((((a % mod) * (a % mod)) % mod), b / 2) % mod)) %
           mod;
}
int64_t a[100001];
int64_t n, m;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int64_t i = 1; i <= n; ++i) cin >> a[i], a[i] %= m;
  map<int64_t, int64_t> m1;
  m1[0] += 1;
  int64_t sum = 0;
  int64_t ans = 0;
  for (int64_t i = 1; i <= n; ++i) {
    sum += a[i];
    sum %= m;
    ans += m1[sum];
    m1[sum]++;
  }
  cout << ans;
}
