#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;
const double PI = 3.1415926535897932;
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  long long sum[n + 1];
  for (int i = 0; i < (int)(n + 1); i++) sum[i] = 0;
  for (int i = 0; i < (int)(n); i++) {
    sum[i + 1] = a[i] + sum[i];
  }
  map<long long, long long> mp;
  long long ans = 0;
  for (int i = 0; i < (int)(n + 1); i++) {
    mp[sum[i] % k]++;
  }
  for (auto i : mp) {
    int x = i.second;
    ans += ((x) * (x - 1)) / 2;
  }
  cout << ans << endl;
}
