#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const long long N = 1e5 + 5, LIM = 1e6 + 5;
long long n, m, a[N], cnt[LIM];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> a[i];
  memset(cnt, 0, sizeof cnt);
  cnt[0]++;
  long long sum = 0, ans = 0;
  for (long long i = 0; i < n; i++) {
    sum += a[i];
    sum %= m;
    ans += cnt[sum];
    cnt[sum]++;
  }
  cout << ans;
  return 0;
}
