def time_statistics(*time):
  """Calculates time statistics. Time is a list of variable length of unix timestamps.
  This function calculates the total duration (first value is assumed beginning, last value is assumed end).
  And from there it calculates the time spent in each phase.

  :param *time: unit time stamps
  :type *time: int
  :return: pre-formatted line
  """
  diff = []
  percentages = []
  total_time = time[-1] - time[0]
  for i, item in enumerate(time):
    if i > 0:
      diff_time = item - time[i-1]
      diff.append(diff_time)

      percent = (diff_time / total_time)*100
      percentages.append(percent)

  total = "Total run time: {0} seconds.".format(total_time)
  percentage = ""
  for i, item in enumerate(percentages):
    if percentage == "":
      percentage = "{0:.3f}% of the time was in phase {{{1}}}".format(item, i)

    else:
      percentage = "{0}, {1:.3f}% of the time was in {{{2}}} phase".format(percentage, item, i)

  line = "\n".join([total, percentage])
  return line