#include <bits/stdc++.h>
using namespace std;
void c() {
  long long int n;
  cin >> n;
  vector<long long int> odd;
  vector<long long int> even;
  int p = 0;
  for (long long int i = 1; i <= 100000000000; i = i * 2) {
    if (p == 1) {
      even.push_back(i);
    } else {
      odd.push_back(i);
    }
    p = (p + 1) % 2;
  }
  map<long long int, int> oddmap;
  map<long long int, int> evenmap;
  for (unsigned long long int i = 0; i < pow(2, odd.size()); ++i) {
    unsigned long long int check = 1;
    long long int count = 0;
    int index = 0;
    for (; check <= i; check = check << 1) {
      if (i & check) {
        count += odd[index];
      }
      index++;
    }
    if (oddmap.count(count) == 0) {
      oddmap[count] = 1;
    }
  }
  for (unsigned long long int i = 0; i < pow(2, even.size()); ++i) {
    unsigned long long int check = 1;
    long long int count = 0;
    int index = 0;
    for (; check <= i; check = check << 1) {
      if (i & check) {
        count += even[index];
      }
      index++;
    }
    if (evenmap.count(count) == 0) {
      evenmap[count] = 1;
    }
  }
  long long int plus = 0, minus = 0;
  for (auto o : oddmap) {
    long long int nest = o.first - n;
    if (evenmap.count(nest) > 0) {
      plus = o.first;
      minus = nest;
    }
  }
  unsigned long long int result = plus + minus;
  string str = "";
  for (unsigned long long int check = 1; check <= result; check = check << 1) {
    if (check & result) {
      str.push_back('1');
    } else {
      str.push_back('0');
    }
  }
  reverse(str.begin(), str.end());
  if (str == "") {
    cout << "0" << endl;
  } else {
    cout << str << endl;
  }
}
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long int result = 0;
  int bound = n / 2;
  vector<long long int> dpbefore(bound, 0);
  vector<long long int> dpafter(ceil(n * 0.5), 0);
  dpbefore[0] = a[0];
  for (int i = 1; i < bound; ++i) {
    dpbefore[i] += dpbefore[i - 1] + a[i];
  }
  dpafter[0] = a[bound];
  for (int i = bound + 1; i < n; ++i) {
    dpafter[i - bound] = dpafter[i - bound - 1] + a[i];
  }
  for (int i = 0; i < bound; ++i) {
    for (int j = i; j < bound; ++j) {
      if (i == 0) {
        if (dpbefore[j] % m == 0) {
          result++;
        }
      } else {
        if ((dpbefore[j] - dpbefore[i - 1]) % m == 0) {
          result++;
        }
      }
    }
  }
  for (int i = 0; i < dpafter.size(); ++i) {
    for (int j = i; j < dpafter.size(); ++j) {
      if (i == 0) {
        if (dpafter[j] % m == 0) {
          result++;
        }
      } else {
        if ((dpafter[j] - dpafter[i - 1]) % m == 0) {
          result++;
        }
      }
    }
  }
  for (int i = 0; i < bound; ++i) {
    long long int before_sum = 0;
    if (i == 0) {
      before_sum = dpbefore.back();
    } else {
      before_sum = dpbefore.back() - dpbefore[i - 1];
    }
    for (int j = 0; j < dpafter.size(); ++j) {
      if ((before_sum + dpafter[j]) % m == 0) {
        result++;
      }
    }
  }
  cout << result << endl;
  return 0;
}
