using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  long n,m;
  cin >> n >> m;
  vector<long> sum(n+1);
  sum.at(0) = 0;
  rep(i,n){
    long a;
    cin >> a;
    sum.at(i+1) = sum.at(i) + a;
  }
  map<long,long> mp;
  rep(i,n+1){
    long tmp = sum.at(i) % m;
    if(mp.count(tmp)) mp.at(tmp)++;
    else mp[tmp] = 1;
  }
  long ans = 0;
  rep(i,m){
    if(mp.count(i)){
      long tmp = mp.at(i) * (mp.at(i) - 1) / 2;
      ans += tmp;
    }
  }
  cout << ans << endl;
}