#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = 3.141592653589793238462;
const int dr[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dc[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
long long a[200005], ans;
map<long long, int> mapi, ok;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1, val; i <= n; i++) {
    cin >> val;
    a[i] = a[i - 1] + val;
    mapi[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (ok[a[i]]) continue;
    ans += (mapi[a[i]] * (mapi[a[i]] - 1)) / 2;
    ok[a[i]] = 1;
  }
  cout << ans + mapi[0] << '\n';
  return 0;
}
