#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000001;
const long long INF = 2e18;
const long long MOD = 1000000007;
const double pi = 3.14159265358979323846;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  vector<long long> sum(n + 1);
  map<int, int> cnt;
  cnt[0] = 1;
  long long res = 0;
  for (int i = 0; i < (int)(n); i++) {
    sum[i + 1] = sum[i] + a[i];
    res += cnt[sum[i + 1]];
    cnt[sum[i + 1]]++;
  }
  cout << res << endl;
}
