#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000;
long long int fac[maxn + 1];
long long int rfac[maxn + 1];
long long int mod = 1e9 + 7;
long long int pow(long long int x, long long int y) {
  if (y == 0) {
    return 1;
  } else if (y == 1) {
    return x;
  } else if (y % 2 == 0) {
    long long int a = pow(x, y / 2);
    return (a * a) % mod;
  } else {
    long long int a = pow(x, (y - 1) / 2);
    return a * a % mod * x % mod;
  }
}
int main() {
  int n;
  long long int a[maxn];
  map<long long int, long long int> m;
  set<long long int> s;
  long long int ans = 0;
  long long int sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  fac[0] = fac[1] = rfac[0] = rfac[1] = 1;
  for (long long int i = 1; i <= maxn; i++) {
    fac[i] = fac[i - 1] * i % mod;
  }
  rfac[maxn] = pow(fac[maxn], mod - 2);
  for (long long int i = maxn; i >= 1; i--) {
    rfac[i - 1] = rfac[i] * i % mod;
  }
  m[0] += 1;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    m[sum] += 1;
    s.insert(sum);
  }
  auto ite = s.begin();
  while (ite != s.end()) {
    long long int cnt = m[*ite];
    if (cnt > 1) {
      long long int add = fac[cnt] * rfac[2] % mod * rfac[cnt - 2] % mod;
      ans += add;
    }
    ite++;
  }
  cout << ans << endl;
  return 0;
}
