#include <bits/stdc++.h>
char num[64];
int first, second;
int check(int n) {
  int ok = 1;
  for (int i = 0; i < n; i++)
    if (num[i] != '4' && num[i] != '7') return 0;
  first = second = 0;
  for (int i = 0; i < n / 2; i++) first += num[i];
  for (int i = n / 2; i < n; i++) second += num[i];
  return (first == second);
}
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", num);
  if (check(n))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
