#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-14;
const double PI = acos(-1.0);
long long combi(int a, int b) {
  int n = max(a, b);
  long long dp[n + 1][n + 1];
  for (int i = (int)(1); i < (int)(n + 1); i++) {
    dp[i][0] = 1;
    dp[i][i] = 1;
  }
  for (int i = (int)(2); i < (int)(n + 1); i++) {
    for (int j = (int)(1); j < (int)(i); j++) {
      dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
    }
  }
  return dp[a][b];
}
int main() {
  int n;
  scanf("%d", &n);
  vector<long long> v(n + 1);
  v[0] = 0;
  for (int i = (int)(0); i < (int)(n); i++) {
    long long a;
    scanf("%lld", &a);
    v[i + 1] = v[i] + a;
  }
  map<long long, int> m;
  for (auto x : v) {
    if (m.count(x))
      m[x] += 1;
    else
      m.insert(make_pair(x, 1));
  }
  long long ans = 0;
  for (auto x : m) {
    if (x.second > 1) {
      ans += combi(x.second, 2);
    }
  }
  printf("%lld\n", ans);
}
