#include<bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<58;
 
int main(){
    ll N; cin >> N;
  	vector<ll> A(N);
    for(ll i = 0; i < N; ++i) cin >> A[i];
  	map<ll,ll> nums;
  	ll sum = 0;
  	nums[sum]++;
  		for (int i = 0; i < N; ++i) {
    		sum += A[i];
    		nums[sum]++;
  		}
  		ll res = 0;
  		for (auto it = nums.begin(); it != nums.end(); ++it) {
    		res += it->second * (it->second - 1) / 2;
  		}
  		cout << res << endl;
    	return 0;
  	}
}