#include <bits/stdc++.h>
using namespace std;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int INF = 1e9;
const long long LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const long long mod = 1000000007;
int n;
map<long long, int> mp;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  long long sum = 0;
  mp[0] = 1;
  for (int i = 0; i < (int)(n); i++) {
    long long tmp;
    cin >> tmp;
    sum += tmp;
    mp[sum]++;
  }
  long long ans = 0;
  for (auto x : mp) {
    if (x.second > 1) ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
}
