#K49702. Discounted Checkout Total Calculation

    ID: 28701 Type: Default 1000ms 256MiB

Discounted Checkout Total Calculation

Discounted Checkout Total Calculation

You are given a list of item prices and a list of indices representing the items purchased from a store. Your task is to calculate the total amount to be paid after applying a discount to the highest priced item among those purchased. The discount is 20% of the maximum price among the chosen items, i.e., \(discount = 0.2 \times \max_{i \in S} price_i\), where \(S\) is the set of purchased items. If no items are purchased, the total amount is \(0.0\).

inputFormat

The input is read from stdin and consists of four parts:

  1. An integer \(N\) representing the number of items in the store.
  2. \(N\) space-separated floating-point numbers representing the prices of each item.
  3. An integer \(M\) representing the number of items purchased.
  4. If \(M > 0\), then \(M\) space-separated integers follow, each representing a 0-indexed position of a purchased item.

outputFormat

Output a single floating-point number to stdout representing the total cost after applying the discount on the highest priced purchased item. The result should be computed with double precision.

## sample
3
10.0 20.0 30.0
3
0 1 2
54.0