#include <bits/stdc++.h>
using namespace std;
long long dp[100005][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> v(n + 1);
  string s[n + 1][2];
  for (long long i = 1; i <= n; i++) cin >> v[i];
  for (long long i = 1; i <= n; i++) {
    cin >> s[i][0];
    s[i][1] = s[i][0];
    reverse(s[i][1].begin(), s[i][1].end());
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < 2; j++) {
      dp[i][j] = 1000000000000000;
      for (long long k = 0; k < 2; k++)
        if (s[i][j] >= s[i - 1][k])
          dp[i][j] = min(dp[i][j], dp[i - 1][k] + j * v[i]);
    }
  }
  long long ans = min(dp[n][0], dp[n][1]);
  if (ans == 1000000000000000)
    cout << -1 << "\n";
  else
    cout << ans;
}
