#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
const int maxn = 1e5 + 5;
int a, sum[maxn];
map<int, int> vis;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    sum[i] = (sum[i - 1] + a + m) % m;
    ans += vis[sum[i]];
    vis[sum[i]]++;
  }
  ans += vis[0];
  cout << ans;
  return 0;
}
