#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<long long> cost(n);
  for (int i = 0; i < n; ++i) {
    cin >> cost[i];
  }
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  vector<vector<long long>> cur(2);
  cur[0].resize(n, 0);
  cur[1].resize(n, 0);
  cur[0][0] = 0;
  cur[1][0] = cost[0];
  vector<vector<int>> possib(2);
  possib[0].resize(n, 0);
  possib[1].resize(n, 0);
  for (int i = 1; i < n; ++i) {
    string prev_rev = s[i - 1];
    reverse(prev_rev.begin(), prev_rev.end());
    if (s[i] >= s[i - 1] && s[i] >= prev_rev) {
      if (possib[0][i - 1] == -1 && possib[1][i - 1] == -1) {
        possib[0][i] = -1;
      } else {
        if (possib[0][i - 1] == -1) {
          possib[0][i] = possib[1][i - 1];
          cur[0][i] = cur[1][i - 1];
        } else {
          if (possib[1][i - 1] == -1) {
            possib[0][i] = possib[0][i - 1];
            cur[0][i] = cur[0][i - 1];
          } else {
            cur[0][i] = min(cur[1][i - 1], cur[0][i - 1]);
          }
        }
      }
    } else {
      if (s[i] >= s[i - 1]) {
        cur[0][i] = cur[0][i - 1];
        possib[0][i] = possib[0][i - 1];
      } else {
        if (s[i] >= prev_rev) {
          cur[0][i] = cur[1][i - 1];
          possib[0][i] = possib[1][i - 1];
        } else {
          possib[0][i] = -1;
        }
      }
    }
    string cur_rev = s[i];
    reverse(cur_rev.begin(), cur_rev.end());
    if (cur_rev >= s[i - 1] && cur_rev >= prev_rev) {
      if (possib[0][i - 1] == -1 && possib[1][i - 1] == -1) {
        possib[1][i] = -1;
      } else {
        if (possib[0][i - 1] == -1) {
          possib[1][i] = possib[1][i - 1];
          cur[1][i] = cur[1][i - 1] + cost[i];
        } else {
          if (possib[1][i - 1] == -1) {
            possib[1][i] = possib[0][i - 1];
            cur[1][i] = cur[0][i - 1] + cost[i];
          } else {
            cur[1][i] = min(cur[0][i - 1], cur[1][i - 1]) + cost[i];
          }
        }
      }
    } else {
      if (cur_rev >= s[i - 1]) {
        cur[1][i] = cur[0][i - 1] + cost[i];
        possib[1][i] = possib[0][i - 1];
      } else {
        if (cur_rev >= prev_rev) {
          cur[1][i] = cur[1][i - 1] + cost[i];
          possib[1][i] = possib[1][i - 1];
        } else {
          possib[1][i] = -1;
        }
      }
    }
  }
  if (possib[0][n - 1] == possib[1][n - 1] && possib[0][n - 1] == -1) {
    cout << -1 << endl;
    return 0;
  }
  if (possib[0][n - 1] == -1) {
    cout << cur[1][n - 1] << endl;
    return 0;
  }
  if (possib[1][n - 1] == -1) {
    cout << cur[0][n - 1] << endl;
    return 0;
  }
  cout << min(cur[0][n - 1], cur[1][n - 1]) << endl;
  return 0;
}
