#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 50;
const int mod = 1e9 + 7;
const int inf = 1e9;
map<long long, int> vis;
int main() {
  int n;
  scanf("%d", &n);
  int ans = 0, sum = 0, ch;
  vis[0] = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &ch);
    sum += ch;
    ans += vis[sum];
    vis[sum]++;
  }
  printf("%d\n", ans);
  return 0;
}
