#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 main() {
  int n, m;
  cin >> n >> m;
  ll s = 0;
  map<int, int> mp;
  for (ll i = 1; i < n + 1; i++) {
    int x;
    cin >> x;
    s += x;
    mp[s % m] += 1;
  }
  ll ans = 0;
  for (auto v : mp) {
    if (v.first == 0) ans += v.second;
    ans += (v.second) * (v.second - 1) / 2;
  }
  cout << ans << endl;
}
