#include <bits/stdc++.h>
using namespace std;
static const long long INF = 1e18;
static const long long MAX = 1e5 + 7;
static const long long MOD = 1e9 + 7;
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
int main(void) {
  long long N, M;
  cin >> N >> M;
  long long s[MAX] = {};
  long long i;
  map<long long, long long> mp;
  mp[0]++;
  for (i = 1; i <= N; i++) {
    long long a;
    cin >> a;
    s[i] = (s[i - 1] + a) % M;
    mp[s[i]]++;
  }
  long long ans = 0;
  for (auto it = mp.begin(); it != mp.begin(); it++) {
    long long t = it->second;
    ans += t * (t - 1) / 2;
  }
  cout << ans << "\n";
}
