Under construction

Still being built. Things may change

Protein Identification

Time limit1sMemory limit512 MB

Summary
Given peaks from an imperfect MS2 experiment, find the minimum number of noise peaks over all P/Q proteins whose total mass equals the largest peak.
Level

Hard9 of 10

Topics
Dynamic programming, Greedy, Math, Combinatorics
Solved
No attempts yet

Problem

A protein is a chain of amino acids. Its sequence can be studied with tandem mass spectrometry (MS2).

For this problem assume the following simplified setting.

  • A protein is a chain of at most 400400 amino acids.
  • There are only two kinds of amino acid, PP and QQ.
  • PP has mass 97.0527697.05276 daltons and QQ has mass 128.05858128.05858 daltons.

The result of an MS2 experiment is a set of real numbers; each number is called a peak. For the true protein, this set contains the mass of every prefix and every suffix of the protein (including the mass of the whole protein) and nothing else. Note that a protein and its reverse produce exactly the same set of prefix and suffix masses.

An experiment on an unknown protein is not perfect, so its result satisfies the following.

  • Some prefix or suffix masses may be missing from the set.
  • The set may contain peaks that are not the mass of any prefix or suffix of the protein. Such a peak is called a noise peak.
  • Every peak is positive.
  • The largest peak equals the mass of the whole protein.
  • Every peak that does correspond to a prefix or suffix mass is exact.

Given the experimental result, consider every protein made of PP and QQ (length at most 400400) whose total mass equals the largest peak. For such a protein, a noise peak is a peak of the input that is not equal to any prefix or suffix mass of that protein. Find the minimum possible number of noise peaks.

Input

The first line contains the number of peaks nn (1≤n≤1000001 \le n \le 100000).

Each of the next nn lines contains one peak pip_i.

The input always satisfies all of the conditions above, and all peaks are distinct. Each peak is given with at most 55 digits after the decimal point.

Output

Print a single integer: the minimum possible number of noise peaks over all proteins made of PP and QQ (length at most 400400) whose total mass equals the largest peak.

Examples3

  1. Example 1

    Input
    6
    225.11134
    353.16992
    353.16991
    291.15828
    97.05276
    128.05858
    
    Expected output
    2
    
  2. Example 2

    Input
    5
    353.16992
    128.05858
    256.11716
    97.05276
    225.11134
    
    Expected output
    0
    
  3. Example 3

    Input
    1
    97.05276
    
    Expected output
    0