272A.md (1984B)
1 Source: https://codeforces.com/problemset/problem/272/A 2 3 A. Dima and Friends 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 Dima and his friends have been playing hide and seek at Dima's place all night. As a result, Dima's place got messy. In the morning they decided that they need to clean the place. 22 23 To decide who exactly would clean the apartment, the friends want to play a counting-out game. First, all the guys stand in a circle, and then each of them shows some number of fingers on one hand (one to five), and then the boys count in a circle, starting from Dima, the number of people, respective to the total number of fingers shown. The person on who the countdown stops will clean the apartment. 24 25 For example, if Dima and one of his friends played hide and seek, and 7 fingers were shown during the counting-out, then Dima would clean the place. If there were 2 or say, 8 fingers shown, then his friend would clean the place. 26 27 Dima knows how many fingers each of his friends will show during the counting-out. Now he is interested in the number of ways to show some number of fingers on one hand (one to five), so that he did not have to clean the place. Help Dima. 28 29 Input 30 31 The first line contains integer *n* (1 ≤ *n* ≤ 100) — the number of Dima's friends. Dima himself isn't considered to be his own friend. The second line contains *n* positive integers, not exceeding 5, representing, how many fingers the Dima's friends will show. 32 33 The numbers in the lines are separated by a single space. 34 35 Output 36 37 In a single line print the answer to the problem. 38 39 Examples 40 41 Input 42 43 ``` 44 1 45 1 46 ``` 47 48 Output 49 50 ``` 51 3 52 ``` 53 54 Input 55 56 ``` 57 1 58 2 59 ``` 60 61 Output 62 63 ``` 64 2 65 ``` 66 67 Input 68 69 ``` 70 2 71 3 5 72 ``` 73 74 Output 75 76 ``` 77 3 78 ``` 79 80 Note 81 82 In the first sample Dima can show 1, 3 or 5 fingers. If Dima shows 3 fingers, then the counting-out will go like that: Dima, his friend, Dima, his friend. 83 84 In the second sample Dima can show 2 or 4 fingers.