#include <bits/stdc++.h>
using namespace std;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
void print(bool f) { cout << (f ? "Yes" : "No") << endl; }
void Print(bool f) { cout << (f ? "YES" : "NO") << endl; }
struct mint {
  long long int x;
  mint(long long int x = 0)
      : x((x % (int)(1e9 + 7) + (int)(1e9 + 7)) % (int)(1e9 + 7)) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= (int)(1e9 + 7)) x -= (int)(1e9 + 7);
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += (int)(1e9 + 7) - a.x) >= (int)(1e9 + 7)) x -= (int)(1e9 + 7);
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= (int)(1e9 + 7);
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long int t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow((int)(1e9 + 7) - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
mint RepeatSquaring(mint N, long long int P, long long int M) {
  if (P == 0) return 1;
  if (P % 2 == 0) {
    mint t = RepeatSquaring(N, P / 2, M);
    return t * t;
  }
  return N * RepeatSquaring(N, P - 1, M);
}
mint combination(long long int n, long long int a) {
  mint x = 1, y = 1;
  for (long long int i = n; i >= n - a + 1; i--) x *= i;
  for (long long int i = a; i >= 1; i--) y *= i;
  y = RepeatSquaring(y, (int)(1e9 + 7) - 2, (int)(1e9 + 7));
  return x * y;
}
int main(void) {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  vector<long long int> sum(n + 1, 0);
  map<long long int, long long int> mp;
  mp[0]++;
  for (long long int i = 1; i < n + 1; i++)
    sum[i] = sum[i - 1] + a[i - 1], mp[sum[i]]++;
  mint ans = 0;
  for (auto x : mp) {
    if (x.second >= 2) ans += combination(x.second, 2);
  }
  cout << ans << endl;
}
