#include <bits/stdc++.h>
using namespace std;
char sum1, sum2;
string n;
int main() {
  int i, j, k, l, m, score, num;
  while (~scanf("%d", &m)) {
    l = 1;
    sum1 = 0;
    sum2 = 0;
    cin >> n;
    for (i = 0; i < m; i++)
      if (n[i] != '4' && n[i] != '7') {
        printf("NO\n");
        l = 0;
        break;
      }
    if (l == 0) continue;
    for (i = 0; i < m / 2; i++) sum1 = sum1 + n[i];
    for (j = i; j < m; j++) sum2 = sum2 + n[j];
    if (sum1 == sum2)
      printf("YES\n");
    else
      printf("NO\n");
  }
}
