#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1000000007;
const long long gosenchou = 5000000000000000;
short gh[2][4] = {{0, 0, -1, 1}, {-1, 1, 0, 0}};
struct P {
  long long pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
  long long to, cost;
};
struct E {
  long long from, to, cost;
};
bool operator<(E a, E b) { return a.cost < b.cost; }
struct H {
  long long x, y;
};
bool operator<(H a, H b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
bool operator>(H a, H b) {
  if (a.x != b.x) return a.x > b.x;
  return a.y > b.y;
}
bool operator==(H a, H b) { return a.x == b.x && a.y == b.y; }
bool operator!=(H a, H b) { return a.x != b.x || a.y != b.y; }
long long gcm(long long i, long long j) {
  if (i > j) swap(i, j);
  if (i == 0) return j;
  return gcm(j % i, i);
}
long double rad(H a, H b) {
  return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}
long long ari(long long a, long long b, long long c) { return (a + b) * c / 2; }
long long fact(long long x, long long k, long long p) {
  long long sum = 1;
  for (int i = 0; i < k; i++) {
    sum *= (x--);
    sum %= p;
  }
  return sum;
}
long long mod_pow(long long x, long long n, long long p) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % p;
    x = x * x % p;
    n >>= 1;
  }
  return res;
}
short ctos(char a) { return (int)(a - '0'); }
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
int n;
int a[300000];
int b[300000];
signed main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int sum = 0;
  int k = 0;
  multiset<int> s;
  s.insert(0);
  for (int i = 1; i <= n; i++) {
    k += a[i];
    sum += s.count(k);
    s.insert(k);
  }
  cout << sum << endl;
}
