Soccer Ball

Time limit1sMemory limit128 MB

Summary
Given per-vertex counts of green panels touching each vertex of a simple closed loop drawn on a truncated icosahedron soccer ball, determine how many of the 12 pentagons, 20 hexagons end up black, white, or green.
Level

Hard8 of 10

Topics
Geometry, Math, Simulation
Solved
No attempts yet

Problem

The official ball of the 1974 FIFA World Cup, the Telstar, is made of 12 black regular-pentagon leather panels and 20 white regular-hexagon leather panels. Each pentagon touches 5 hexagons, and each hexagon touches 3 pentagons and 3 hexagons.

On this ball, Wonseop drew a single closed polygon (a loop) that follows the edges of the panels and does not cross itself. He then painted every leather panel inside that polygon green.

Given the description of the polygon Wonseop drew, write a program that computes how many panels remain black, how many remain white, and how many were painted green.

Input

The first line contains nn, the number of vertices of the polygon. The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n separated by spaces. Each aia_i is 11 or 22 and equals the number of green (i.e. inside-the-polygon) panels that touch the ii-th vertex of the polygon. The vertices are given in order along the polygon, and the edge joining the nn-th vertex and the first vertex always lies on an edge shared by two hexagons.

Output

Print, on one line, the number of black panels, the number of white panels, and the number of green panels, separated by spaces.

Examples2

  1. Example 1

    Input
    21
    1 2 1 2 1 2 1 1 1 2 2 1 1 1 1 2 2 2 1 1 1
    
    Expected output
    11 15 6
    
  2. Example 2

    Input
    6
    1 1 1 1 1 1
    
    Expected output
    12 19 1