-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractical_3_2.java
More file actions
31 lines (27 loc) · 817 Bytes
/
Practical_3_2.java
File metadata and controls
31 lines (27 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Practical_3_2 {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int [] arr = new int[n];
for(int i=0;i<n;i++){
arr[i] = sc.nextInt();
}
int count=0;
for(int i=0;i<n;i++){
int sum=0;
for(int j=i;j<n;j++){
sum = sum + arr[j];
if(sum<0){
count++;
}
}
}
System.out.println(count);
}
}