#include <bits/stdc++.h>
using namespace std;
const int M = 100010;
const int inf = 1000000007;
const long long INF = 1000000000000000007;
using ll = long long;
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
int comb(int x) {
  ll ans = 1;
  ans = x * (x - 1) / 2;
  return ans;
}
int main() {
  ll n, m, ans = 0;
  int a, dp[M] = {};
  cin >> n >> m;
  for (ll i = 0; i < n; i++) {
    cin >> a;
    dp[i + 1] = (dp[i] + a) % m;
  }
  sort(dp + 1, dp + n + 1);
  for (ll i = 1; i < n + 1; i++) {
    if (dp[i] == 0)
      ans++;
    else
      break;
  }
  for (ll i = 1; i < n + 1; i++) {
    int cnt = 1;
    for (ll j = i + 1; j < n + 1; j++) {
      if (dp[i] == dp[j])
        cnt++;
      else
        break;
    }
    ans += comb(cnt);
    i += cnt - 1;
  }
  cout << ans << endl;
}
