Seven people were wounded in a shooting at a barbecue in Brooklyn late Monday night.

Police said a 21-year-old man tried to enter the party at an apartment on Chauncey Street near Saratoga Avenue in Bedford-Stuvyesant around 11:30 p.m., and when he wasn’t allowed in, he opened fire.

Police said the spray of bullets struck three women and four men.

A 19-year-old woman who was hit in the hand, an 18-year-old man who was struck in the shoulder and a 20-year-old man who was shot in the back were taken to Brookdale University Hospital and Medical Center, according to police.

A 20-year-old woman who was shot in the cheek, an 18-year-old man who was struck in the arm, a 19-year-old man who was hit in the back and a 17-year-old woman who suffered wounds to her leg, back and arm were all taken to Kings County Hospital Center, police said.

All of the victims are expected to survive, police said.

An NYPD spokesman said a 21-year-old man is in police custody and that charges are pending.

Police said there were a total of 12 shootings that left 20 people injured in Manhattan, Brooklyn, Queens and Staten Island on July 4.