#include <bits/stdc++.h>
using namespace std;
class Solver {
 public:
  void solve() {
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    long long sum = 0, ans = 0;
    map<long long, long long> preSum;
    for (int u = 1; u <= N; u++) {
      long long A;
      cin >> A;
      ans += preSum[sum % M];
      if (sum % M == 0) ans++;
      preSum[sum % M]++;
      sum += A;
    }
    cout << ans;
  }
};
int main() { (new Solver())->solve(); }
