#include <bits/stdc++.h>
const int magicconst = 73743071;
int main() {
  int n;
  scanf("%d\n", &n);
  int sum = 0;
  for (int i = 0; i < (int)(n); ++i) {
    char ch;
    scanf("%c", &ch);
    if (ch != '4' && ch != '7') {
      printf("NO");
      return 0;
    }
    if (i < n / 2)
      sum += ch - '0';
    else
      sum -= ch - '0';
  }
  if (sum)
    printf("NO");
  else
    printf("YES");
  return 0;
}
