#include <bits/stdc++.h>
using namespace std;
const long long kMaxN = 100000;
const long long kMaxM = 1000000000;
long long N, M;
long long A[kMaxN];
long long ans = 0;
bool checked[kMaxN];
signed main() {
  cin >> N >> M;
  for (long long i = 0; i < (N); ++i) {
    cin >> A[i];
  }
  for (long long ii = 0; ii < (N); ++ii) {
    if (checked[ii]) {
      continue;
    }
    bool next_j_exists = true;
    long long i = ii;
    long long cnt = 0;
    while (next_j_exists) {
      long long sum = 0;
      long long j = i;
      while (true) {
        sum = (sum + A[j]) % M;
        if (sum == 0) {
          break;
        }
        if (j + 1 < N) {
          ++j;
        } else {
          next_j_exists = false;
          break;
        }
      }
      checked[i] = true;
      if (!next_j_exists) {
        break;
      }
      ++cnt;
      if (j + 1 < N) {
        i = j + 1;
      } else {
        next_j_exists = false;
      }
    }
    ans += cnt * (cnt + 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
