#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args>
void dbg(Args&&... args) {
  using expander = int[];
  (void)expander {0,(static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {exit(0);}

const int N = 1e5 + 5;
const int M = 1e9 + 5;
int n, m;
int a[N];

void input() {
  scanf("%d %d", &n, &m);
  forn(i, 0, n) {
    scanf(" %d", &a[i]);
  }
}

ll ans = 0;
int counts[M];
int mods[N];

void solve() {
  forn(i, 0, n) {
    mods[i] += ((i == 0 ? 0 : mods[i - 1]) + a[i]) % m;
    ans += counts[(mods[i]) % m] + (mods[i] == 0);
    counts[mods[i]]++;
  }
 
  printf("%lld\n", ans);
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
  //  gen();
#endif
  input();
  solve();
  return 0;
}
