#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int N, M;
int A[100010];
ll B[100010];
map<ll, int> mp;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i + 1] = A[i] + B[i];
  }
  mp[0]++;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    B[i] %= M;
    ans += mp[B[i]];
    mp[B[i]]++;
  }
  cout << ans << endl;
  return 0;
}
