The design of a multi-subject fMRI experiment needs specification of the number of subjects and scanning time per subject. For example, for a blocked design with conditions A or B, fixed block length and block order ABN, where N denotes a null block, the optimal number of cycles of ABN and the optimal number of subjects have to be determined. This paper presents a method to determine the optimal number of subjects and optimal number of cycles for a blocked design based on the A-optimality criterion and a linear cost function by which the number of cycles and the number of subjects are restricted. Estimation of individual stimulus effects and estimation of contrasts between stimulus effects are both considered. The mixed-effects model is applied and analytical results for the A-optimal number of subjects and A-optimal number of cycles are obtained under the assumption of uncorrelated errors. For correlated errors with a first-order autoregressive (AR1) error structure, numerical results are presented. Our results show how the optimal number of cycles and subjects depend on the within- to between-subject variance ratio. Our method is a new approach to determine the optimal scanning time and optimal number of subjects for a multi-subject fMRI experiment. In contrast to previous results based on power analyses, the optimal number of cycles and subjects can be described analytically and costs are considered.