import std;

void main() {
  int N; long M;
  scan(N, M);
  auto a = readln.split.to!(long[]).map!(x => x % M).array;
  
  long[long] cnt;
  cnt[0] = 1;
  long rem;
  long ans;
  
  foreach (i; 0 .. N) {
    rem = (rem + a[i]) % M;
    if (rem in cnt) ans += cnt[rem];
    cnt[rem]++;
  }
  
  writeln(ans);
}
  


void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}
 
void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
 
bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}
 
bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}
 
void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}