#include <bits/stdc++.h>
using namespace std;
const pair<int, int> DIR[] = {{1, 0}, {0, 1},  {-1, 0},  {0, -1},
                              {1, 1}, {-1, 1}, {-1, -1}, {1, -1}};
const int INF_32 = -1 + (1 << 30);
const long long INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;
unsigned long long next_subset(unsigned long long subset) {
  unsigned long long tem = subset + (subset & -subset);
  unsigned long long btm = (~tem & subset) / (subset & -subset) >> 1;
  return btm | tem;
}
int N;
long long s[200001], ans = 0;
void solve() {
  sort(s, s + N + 1);
  int i = 0;
  while (i <= N) {
    int j = i + 1;
    while (s[j] == s[j - 1]) ++j;
    ans += (long long)(j - i) * (j - i - 1) / 2;
    i = j;
  }
  cout << ans << endl;
  return;
}
void input() {
  cin >> N;
  s[0] = 0;
  for (int(i) = 0; (i) < (N); ++(i)) {
    int a;
    cin >> a;
    s[i + 1] = s[i] + a;
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  solve();
  return 0;
}
