Problem: Problem Statement

Infinite Chronicle -Princess Castle- is a simple role-playing game. There are $n + 1$ checkpoints, numbered $0$ through $n$, and for each $i = 1, 2, \ldots, n$, there is a unique one-way road running from checkpoint $i - 1$ to $i$. The game starts at checkpoint $0$ and ends at checkpoint $n$. Evil monsters will appear on the roads and the hero will have battles against them. You can save your game progress at any checkpoint; if you lose a battle, you can restart the game from the checkpoint where you have saved for the last time. At the beginning of the game, the progress is automatically saved at checkpoint $0$ with no time.

Rabbit Hanako is fond of this game and now interested in speedrunning. Although Hanako is an expert of the game, she cannot always win the battles because of random factors. For each $i$, she estimated the probability $p_i$ to win all the battles along the road from checkpoint $i - 1$ to $i$. Everytime she starts at checkpoint $i - 1$, after exactly one miniutes, she will be at checkpoint $i$ with probability $p_i$ and where she saved for the last time with probability $1 - p_i$.

What puzzles Hanako is that it also takes one minute (!) to save your progress at a checkpoint, so it might be a good idea to pass some checkpoints without saving in order to proceed quickly. The task is to compute the minimum possible expected time needed to complete the game.

Input

The input consists of multiple datasets. The number of datasets is no more than $50$. Each dataset has two lines: the first line contains an integer $n$ ($1 \le n \le 10^5$), representing the number of roads, and the second line contains $n$ numbers $p_1, p_2, \ldots, p_n$ ($0 \lt p_i \le 1$), representing the winning probabilities. Each $p_i$ has exactly two digits after the decimal point. The end of input is denoted as a line containing only a single zero.

Output

For each dataset, display the minimum expected time in minutes with a relative error of at most $10^{-8}$ in a line.

Sample Input


2
0.50 0.40
2
0.70 0.60
4
0.99 1.00 1.00 0.01
0

Output for the Sample Input


5.5000000000
4.0476190476
104.0101010101





Example

Input

2
0.50 0.40
2
0.70 0.60
4
0.99 1.00 1.00 0.01
0


Output

5.5000000000
4.0476190476
104.0101010101

Solution (in CPP):

Solution:
//
//  main.cpp
//
//  Under GPLv3 license
//

// #pragma GCC diagnostic error "-std=c++14"
// #pragma GCC optimize("O3")
// #pragma comment(linker, "/STACK:1024000000,1024000000")

#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define pf push_front
#define mp make_pair

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10;
const int N = 1e5 + 1000;
const int LEN = 50;

int T;
int n;
vector<double> p;
double dp[N];

void init() {
  p.clear();
  memset(dp, 0, sizeof dp);
}

int main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);

#ifndef ONLINE_JUDGE
  double __start_time = clock();
#endif

  // insert code heree

  while (scanf("%d", &n)) {
    if (n == 0) break;
    init();

    double buff = 0.00;
    for (int i = 0; i < n; i++) {
      double x;
      scanf("%lf", &x);
      if (x == 1.00) {
        buff += 1.00;
      } else {
        if (buff > 0) p.pb(buff), buff = 0.00;
        p.pb(x);
      }
    }

    if (buff > 0) p.pb(buff);

    n = (int)p.size();

    dp[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
      dp[i] = INF;
      buff = 0;

      for (int j = i + 1; j <= n && j - i <= LEN; j++) {
        if (p[j - 1] < 1.00)
          buff = (buff + 1.00) / p[j - 1];
        else
          buff += p[j - 1];
        dp[i] = min(dp[i], buff + dp[j] + 1);
      }
    }

    printf("%.8lf\n", dp[0] - 1.00);
  }

#ifndef ONLINE_JUDGE
  cout << "LOCAL RUNNING TIME = "
       << double(((double)clock() - __start_time) / (double)CLOCKS_PER_SEC)
       << " sec" << endl;
#endif

  return 0;
}