#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n + 1);
  a[0] = 0;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    a[i + 1] = a[i] + t;
  }
  ll cnt = 0;
  for (int i = 1; i < n + 1; ++i) {
    if (a[i] % m == 0) cnt++;
  }
  ll sum = 0;
  for (ll i = 0; i <= cnt; ++i) sum += i;
  cout << sum << endl;
  return 0;
}
