#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  map<int, int> amari;
  amari[0] = 1;
  int ruiseki = 0;
  int ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    ruiseki += a[i];
    ruiseki %= m;
    if (amari.count(ruiseki)) {
      ans += amari[ruiseki];
      amari[ruiseki]++;
      continue;
    }
    amari[ruiseki] = 1;
  }
  cout << ans << endl;
}
