#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp;
const int maxn = 2e5;
int n, m;
int a[maxn];
long long pre[maxn];
int cnt[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pre[i] = pre[i - 1] + a[i];
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += mp[pre[i] % m];
    if (pre[i] % m == 0) ans++;
    mp[pre[i] % m]++;
  }
  cout << ans << endl;
}
